最近一个Delphi项目中需要组合多条SQL语句执行,期间用到了Uniadc 组件连接sqlite数据库。关于组合多条SQL语句的代码如下,供参考:
//以下组合多条sql语句
UniQuery1.Close;
UniQuery1.sql.Clear;
//UniQuery1.sql.Add(' begin'); //不需要Begin,会出错
UniQuery1.SQL.Add(' update tbChildNetwork set isSelected=0;'); //正确
UniQuery1.SQL.Add('insert into tbChildNetwork(netid,NETNAME,Com_ID,ip,port,isSelected'+')values('''+netid.ToString+''','''+NETNAME+''','''+Com_ID+''','''+ip+''','''+port+''','''+'1'+''')'); //正确
//UniQuery1.sql.Add(' end;'); //不需要end,会出错
UniQuery1.ExecSQL;