Monday, 15 June 2015

c# - Commit and rollback Oracle transactions -



c# - Commit and rollback Oracle transactions -

i'm calling proc in c# oracle. made proc homecoming error. in other words proc fails , pv_error populated string , rollback gets triggered, doesn't work. i'm not sure why. so, doing wrong? in advance.

private void hhrcv_update_dc_grs_carton() { oraclecommand cmd = new oraclecommand(); cmd.connection = conn; conn.open(); oracletransaction trans = conn.begintransaction(); cmd.commandtimeout = 0; cmd.commandtext = "dc.hhrcv_update_dc_grs_carton"; cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add("pn_dc_grs_no", oracledbtype.number).value = txtdcgrsno.text; cmd.parameters.add("pn_pallet_id_no", oracledbtype.number).value = txtpalletid.text; cmd.parameters.add("pn_carton_code", oracledbtype.varchar).value = txtcartoncode.text; cmd.parameters.add("pn_company_id_no", oracledbtype.number).value = companyid; cmd.parameters.add("pn_order_no", oracledbtype.number).value = txtorderno.text; cmd.parameters.add("pn_emp_id_no", oracledbtype.number).value = empid; cmd.parameters.add(new oracleparameter("pv_error", oracledbtype.varchar)); cmd.parameters["pv_error"].direction = parameterdirection.output; string pv_error; cmd.executenonquery(); pv_error = cmd.parameters["pv_error"].value.tostring(); if (pv_error.tostring() == "") { trans.commit(); } else { trans.rollback(); messagebox.show("" + pv_error, "error"); frmreturns r = new frmreturns(); r.show(); this.hide(); } } the stored procedure not committing oracle sql developers autocommit disabled when run stored procedure in oracle sql developers works (fails - have made , doesn't commit) only when running stored procedure in vs2005 proc fails, triggers rollback doesn't execute it

most need add:

cmd.transaction = tran;

after calling begintransaction.

without runtime not know cmd part of transaction tran!

for details see the documentation.

c# oracle stored-procedures

No comments:

Post a Comment