利用UltraEdit快速將SQL語句轉換爲符合VB.NET語法格式字符串

實習中時常需要將寫好的SQL語句嵌入到VB.NET的函數中,例如將下列SQL:
ContractedBlock.gifExpandedBlockStart.gif-- Get Mother Lot Common Info
None.gifselect c.customerlotnumber -- customer lot#
None.gif
,c.containername --Amkor lot#,
None.gif
,amk.description
None.gif,inh.txndate indate
--s_time
None.gif
,outh.txndate  outdate -- e-time
None.gif
,rs.resourcename resourcename
None.gif,emp.fullname
None.gif

-- ,outh.qty
None.gif
from container c,historymainline hml,workflowstep wfs
None.gif,operation opt,movehistory outh,moveinhistory inh
None.gif,RESOURCEDEF rs
None.gif,amkorwwoper amk
None.gif,employee emp
None.gif




where c.splitfromid =(select containerid from container where
None.gifcontainername
='ML6410058461')
None.gif
and hml.reversalstatus=1
None.gif
and c.containerid=hml.containerid
None.gif
and hml.operationid=opt.operationid
None.gif
and hml.workflowstepid=wfs.workflowstepid
None.gif
and hml.operationid=opt.operationid
None.gif
and hml.historymainlineid=inh.historymainlineid(+)
None.gif
and hml.historymainlineid=outh.historymainlineid(+)
None.gif
and HMl.RESOURCEID=RS.RESOURCEID(+)
None.gif
and (outh.historymainlineid is not null or inh.historymainlineid is not null)
None.gif
and opt.amkorwwoperid=amk.amkorwwoperid
None.gif
and hml.employeeid=emp.employeeid
None.gif
order by c.containername,to_number(wfs.sequence),inh.txndate,outh.txndate

轉換如下形式爲:
ContractedBlock.gifExpandedBlockStart.gifString sql in VB.NET
None.gifsql = "select c.customerlotnumber -- customer lot# " & vbCrLf _  
None.gif  
& ",c.containername --Amkor lot#, " & vbCrLf _  
None.gif  
& ",amk.description " & vbCrLf _  
None.gif  
& ",inh.txndate indate--s_time " & vbCrLf _  
None.gif  
& ",outh.txndate  outdate -- e-time " & vbCrLf _  
None.gif  
& ",rs.resourcename resourcename " & vbCrLf _  
None.gif  
& ",emp.fullname " & vbCrLf _  
None.gif  
& "-- ,outh.qty " & vbCrLf _  
None.gif  
& "from container c,historymainline hml,workflowstep wfs " & vbCrLf _  
None.gif  
& ",operation opt,movehistory outh,moveinhistory inh " & vbCrLf _  
None.gif  
& ",RESOURCEDEF rs " & vbCrLf _  
None.gif  
& ",amkorwwoper amk " & vbCrLf _  
None.gif  
& ",employee emp " & vbCrLf _  
None.gif  
& "where c.splitfromid =(select containerid from container where " & vbCrLf _  
None.gif  
& "containername='ML6410058461') " & vbCrLf _  
None.gif  
& "and hml.reversalstatus=1 " 'dot.gif..

同事Tracy告訴我一個快速方法,僅僅利用UltraEdit的查找替換功能(<>號不填,僅爲引用號),
查找:< ^p >
替換:<  " & vbCrLf _  ^p  & " >
替換的第一個"號前不可省去空格,然後填上頭尾即可,^p代表回車符,也就是將回車符展開,是不是很有趣的技巧?555134.html

丁丁 2006-11-09 11:52 發表評論







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章