I'm using a procedure to insert data in my firebird database. This procedure is called in a while command because there is no limit for how many items I can insert, for example:
while (there's itens) {
query("select * from procedure_insert(id,desc,etc);");
}
This doesn't work, after I finish my insertion not a single item is inserted in the database. My procedure works fine there's no doubt, I believe it's a problem with the class I use to query and commit
Here is my code:
Persistence class:
public class Persistence {
public static Connection con = Conn.getConn();
public static Statement stm = null;
public static void Conn(){
try {
stm = con.createStatement();
} catch (SQLException e) {
//
}
}
public static void Insert(String query) {
try {
stm.execute(query);
} catch (SQLException e) {
//
}
}
public static void Commit(){
try {
con.commit();
} catch (SQLException e) {
//
}
}
Insert:
while(rs.next()){
Items item = new Items();
item.setItem_data(rs.getString("ZPED_ITEM_DATA"));
item.setItem_desconto(rs.getDouble("ZPED_ITEM_VALOR_V") - rs.getDouble("ZPED_ITEM_DESCONTO"));
item.setItem_produto(rs.getInt("ZPED_ITEM_PRODUTO"));
item.setItem_qtd(rs.getDouble("ZPED_ITEM_QTD"));
item.setItem_valor_v(rs.getDouble("ZPED_ITEM_VALOR_V"));
item.setPed_cod(rs.getInt("ZPED_COD"));
////////////////////////////////////////////////////////////////
Persistence.Insert("SELECT * FROM PEDIDOS_PROC("+a+","+b+","+p.get(0).getCod_n()+",'"+p.get(0).getData()+"',55,"+item.getItem_produto()+",0,"+item.getItem_qtd()+","+item.getItem_valor_v()+",'A',2);");
Persistence.Commit();
}
thank you!
I'm using JDBC Jaybird Full 2.2.7
is PEDIDOS_PROC selectable procedure? If no you must to execute it
execute procedure PEDIDOS_PROC(params...)