1 package codewiz; 2 3 import dinamica.*; 4 5 14 public class SQLBatch extends GenericTransaction 15 { 16 17 20 public int service(Recordset inputs) throws Throwable 21 { 22 23 int rc = super.service(inputs); 25 26 String sql = inputs.getString("sql"); 27 28 String cmd[] = StringUtil.split(sql,";"); 29 30 Recordset rs = new Recordset(); 31 rs.append("sql",java.sql.Types.VARCHAR); 32 rs.append("status",java.sql.Types.VARCHAR); 33 34 Db db = getDb(); 35 36 for (int i=0;i<cmd.length;i++) 37 { 38 rs.addNew(); 39 rs.setValue("sql", cmd[i]); 40 rs.setValue("status", "OK"); 41 try { 42 db.exec(cmd[i]); 43 } 44 catch (Throwable e) 45 { 46 rs.setValue("status", e.getCause().getMessage()); 47 } 48 } 49 50 publish("sql",rs); 51 52 return rc; 53 54 } 55 56 } 57 | Popular Tags |