代码详解 ( 积分: 30 )

  • 主题发起人 主题发起人 wl821205
  • 开始时间 开始时间
W

wl821205

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure&nbsp;Tqc_mainForm.add_qc1_field;<br>var&nbsp;s,s1,s2:string;<br>begin<br>&nbsp;&nbsp;query3.sql.Clear;<br>&nbsp;&nbsp;query3.close;<br>&nbsp;&nbsp;s:='SELECT&nbsp;OBJECT_ID(&quot;'+database_name+'&quot;)&nbsp;as&nbsp;abc';<br>&nbsp;&nbsp;query3.sql.add(s);<br>&nbsp;&nbsp;query3.open;<br>&nbsp;&nbsp;s1:=inttostr(query3.fieldbyname('abc').asinteger);<br>&nbsp;&nbsp;query3.sql.Clear;<br>&nbsp;&nbsp;query3.close;<br>&nbsp;&nbsp;s:='if&nbsp;(select&nbsp;object_id(&quot;lsk&quot;))&nbsp;is&nbsp;not&nbsp;NULL&nbsp;drop&nbsp;table&nbsp;lsk'+#13;<br>&nbsp;&nbsp;s:=s+'SET&nbsp;NOCOUNT&nbsp;OFF'+#13+'SELECT&nbsp;COL_NAME('+s1+',&nbsp;ORDINAL_POSITION)&nbsp;as&nbsp;bb&nbsp;into&nbsp;lsk&nbsp;FROM&nbsp;INFORMATION_SCHEMA.COLUMNS&nbsp;WHERE&nbsp;(TABLE_NAME&nbsp;=&quot;'+database_name+'&quot;)&nbsp;and&nbsp;(substring(COL_NAME('+s1+',&nbsp;ORDINAL_POSITION),1,3)=&quot;sec&quot;)';<br>&nbsp;&nbsp;query3.sql.add(s);<br>&nbsp;&nbsp;query3.execsql;<br>&nbsp;&nbsp;query3.sql.Clear;<br>&nbsp;&nbsp;query3.close;<br>&nbsp;&nbsp;s:='select&nbsp;*&nbsp;from&nbsp;qc_no&nbsp;where&nbsp;sec_no&nbsp;not&nbsp;in&nbsp;(select&nbsp;bb&nbsp;from&nbsp;lsk)';<br>&nbsp;&nbsp;query3.sql.add(s);<br>&nbsp;&nbsp;query3.open;<br>&nbsp;&nbsp;while&nbsp;not&nbsp;query3.Eof&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;s2:=query3.fieldbyname('sec_no').asstring;<br>&nbsp;&nbsp;&nbsp;&nbsp;query2.sql.Clear;<br>&nbsp;&nbsp;&nbsp;&nbsp;query2.close;<br>&nbsp;&nbsp;&nbsp;&nbsp;s:='ALTER&nbsp;TABLE&nbsp;'+database_name+'&nbsp;ADD&nbsp;'+s2+'&nbsp;int&nbsp;default&nbsp;0';<br>&nbsp;&nbsp;&nbsp;&nbsp;query2.sql.add(s);<br>&nbsp;&nbsp;&nbsp;&nbsp;query2.execsql;<br>&nbsp;&nbsp;&nbsp;&nbsp;query3.next;<br>&nbsp;&nbsp;end;<br>以上代码,请哪个大哥帮我详细解说明一下好吗?
 
全是SQL语句,会用的都应该看得明白。<br>不过我没看完,所以我不明白。<br>不过看了两眼。自己看看吧。
 
后退
顶部