oracle11g - .net Oracle Data Provider transaction rollback not working -
So this is the problem.
I need to put it in table A. and get its new line ID. After that, let me put that ID into table B. I should do this after joining the table A. so that when I try to include in Table B, I will not get any foreign key exceptions.
Now, my understanding was that if an exception has been raised in the function which is included in Table B. When the attempt-catch block catches the exception, the original entry rollback will be in the table. It is not doing this.
I am making a mistake somewhere, but I do not know, is there any way to complete this that I need here?
Try {tableAinsert.ExecuteNonQuery (); Transaction.Commit (); Id = Int32.Parse (tableAinsert.Parameters ["id"]. Value.ToString ()); If (vs type == "i") {tablebint (vs type, event id, id); }} Hold (exception mistake) {transaction.Rollback (); Throw (mistake); There, one of my colleagues told the problem there,
It seems that the same connection should be used and the same transaction should be able to roll back a multi-step entry like this. And that per transaction can only be committed one.
This means that for each of my work, the connection and transaction orders must be modified, accept the OracleConnection and OracleTransaction arguments first and commit () code and other related line.
So I modified the code I posted, it will look like this
OracleConnection conn = new OracleConnection (); // .... Create your own command, set connection string, etc., etc. var transaction = conn.BegginTransaction (); CMD. Transaction = transaction; {Try TableAinsert.ExecuteNonQuery (); Id = Int32.Parse (tableAinsert.Parameters ["id"]. Value.ToString ()); If (vs type == "i") {tablebint (versus type, event id, id, conn, transaction); } Transactions. Communications (); // it was moved to the end of the block} hold (exception mistake) {transaction.Rollback (); Throw (mistake); }
Comments
Post a Comment