cool_ravi2 has asked for the wisdom of the Perl Monks concerning the following question:
When I run this code and some kind of database error occurs in update query number 3. The rest of the updates from 3 to n do take place. But since the status is now false, the database has to do a rollback. But the problem is that the updates 1 and 2 get rolled back but the updates that were done after query 3( where the database error occured ) are not rolled back.use Sybase::DBlib; my $dbh = new Sybase::DBlib( <username>, <password>, <server> ); #A reference to my own error handler for sybase errors dberrhandle( \&myerrorhandler ); # if status flag is 1 then transaction was successful else the transac +tion was not successful $status = 1; sub myerrorhandler { < when error occurs the status flag $status is set to 0 > $status &=0; &INT_CANCEL; # in order to continue with the rest of the process } $dbh->nsql( "begin transaction" ); $dbh->nsql( <update query 1> ); . . . $dbh->nsql( <update qurey n> ); if ( $status ) { $dbh->nsql( "commit" ); } else { $dbh->nsql( "rollback" ); }
Could someone pls tell me about this unpredictable behavior and how can we get around this problem.
Thank you,
Ravi Malayambakkam.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sybperl - Problem with Handling Transactions with Commit and Rollback
by Aragorn (Curate) on May 16, 2003 at 14:36 UTC | |
|
Re: Sybperl - Problem with Handling Transactions with Commit and Rollback
by VSarkiss (Monsignor) on May 16, 2003 at 14:53 UTC | |
|
Re: Sybperl - Problem with Handling Transactions with Commit and Rollback
by derby (Abbot) on May 16, 2003 at 15:07 UTC |