sql转换为stringBuffer的小工具,dao层拼接sql很麻烦,用这个小工具可以快速拼接,把写好的sql在sql工具中格式化好,然后复制进去就可以了
演示地址:http://runjs.cn/detail/fj14tpyu 有点丑,建议全屏查看,不过你下载下来可以自己修改
代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>change SQL</TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script> var ie = !-[1,]; function changeSQL(){ var srcSQL = document.getElementById("srcSQL"); var srcInner = srcSQL.value; var sqlBuf = "sqlBuf" var BufObj = "StringBuffer sqlBuf = new StringBuffer();" var newSrc = ""; if(ie){ var newSrc = srcInner.split("\r\n"); }else{ var patt = new RegExp(/.+/g); var newSrc = srcInner.match(patt); } var len = newSrc.length; for(var i=0;i<len;i++){ var temp=newSrc[i]; if(i < len-1){ sqlBuf += ".append(\" " + temp + " \")" + "\r\n"; } if(i == len-1){ sqlBuf += ".append(\" " + temp + " \");"; } } var showSQL = document.getElementById("showSQL"); showSQL.innerText = BufObj + "\n" + sqlBuf; } </script> </HEAD> <BODY> <table border="1" width="100%" > <tr align="center"> <td width="45%"><textarea id="srcSQL" rows="40" cols="85" ></textarea></td> <td> <button onclick="changeSQL()" style="cursor:hand;"><font color="blue" size="5"><b>转换</b></button><p> </td> <td width="45%"><textarea id="showSQL" rows="40" cols="85" ></textarea></td> </tr> </table> </BODY> </HTML>
以上所述就是本文的全部内容了,希望大家能够喜欢。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“javascript制作sql转换为stringBuffer的小工具”评论...