标签:
oracle逗号字符串拼接小工具
http://www.zui#dai#ma.com/share/1932670249667584.htm
在使用oracle进行数据查询时,常常需要使用到in语句,如果id是execl中导出的,难道要一个一个的写么,这里提供一个小工具,可以快速拼接in语句。
代码如下:
01 |
function changeSQL(){ |
02 |
var srcSQL = document.getElementById( "srcSQL" ); |
03 |
var srcInner = srcSQL.value; |
04 |
var sqlBuf = "in ( " |
05 |
|
06 |
var newSrc = "" ; |
07 |
if (ie){ |
08 |
var newSrc = srcInner.split( "\r\n" ); |
09 |
} else { |
10 |
var patt = new RegExp(/.+/g); |
11 |
var newSrc = srcInner.match(patt); |
12 |
} |
13 |
var len = newSrc.length; |
14 |
for ( var i=0;i<len;i++){ |
15 |
var temp=newSrc[i]; |
16 |
if (i < len-1){ |
17 |
sqlBuf += "\‘" +temp+ "\‘" + "," ; |
18 |
} |
19 |
if (i == len-1){ |
20 |
sqlBuf += "\‘" +temp+ "\‘)" ; |
21 |
} |
22 |
} |
23 |
|
24 |
var showSQL = document.getElementById( "showSQL" ); |
25 |
showSQL.innerText = sqlBuf; |
26 |
} |
01 |
< table border = "1" width = "350" height = "450" > |
02 |
< tr align = "center" > |
03 |
< td width = "45%" >< textarea id = "srcSQL" rows = "28" cols = "60" ></ textarea ></ td > |
04 |
< td > |
05 |
< button onclick = "changeSQL()" style = "cursor:hand;" >< font color = "blue" size = "5" >< b >转换</ b ></ button >< p > |
06 |
|
07 |
</ td > |
08 |
< td width = "45%" >< textarea id = "showSQL" rows = "28" cols = "60" ></ textarea ></ td > |
09 |
</ tr > |
10 |
</ table > |
标签:
原文地址:http://www.cnblogs.com/Leo_wl/p/5533416.html