我要一次执行3句SQL,但是
我用了;不行
应该是什么?
------解决方案--------------------
------------------或者这样写----------------
try {
String sql = " insert into social.grant4(personid,yearfr,monthfr,yearto,monthto,fee,operator,opertime) ";
sql += " select s.personid,@yearfr,@monthfr,@yearto,@monthto,@fee,@operator,GetDate() ";
sql += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql1 += " insert into social.grant3(commid,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql1 += " select c.commid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql1 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql1 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql1 += " group by c.commid ";
sql2 += " insert into social.grant2(streetid,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql2 += " select t.streetid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql2 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql2 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql2 += " group by t.streetid ";
sql3 += " insert into social.grant1(branch,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql3 += " select t.branchid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql3 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql3 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql3 += " group by t.branchid ";
conn = DbManager.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt1 = conn.prepareStatement(sql1);
pstmt1.executeUpdate();
pstmt2 = conn.prepareStatement(sql2);
pstmt2.executeUpdate();
pstmt3 = conn.prepareStatement(sql3);
pstmt3.executeUpdate();