On Monday, January 7, 2002, at 08:17 AM, Tim Bunce wrote:
> Umm, these days you'd use $dbh->begin_work, right? > >> I didn't see this in my version of DBI, which I thought was 1.20 but indeed it is documented in the docs on CPAN. The documented behavior is the same as the methods in DBIx.pm except that after a rollback, the $dbh is put into AutoCommit mode. The one advantage of DBIx.pm is that it keeps count of the number of transaction open and closes so that if a $dbh goes out of scope, the DESTROY method can throw a warning if the opens and closes are not balanced. >> s $@; >> rollback_transaction $dbh and return 'ERROR'; >> } >> >> begin_transaction $dbh; >> eval { >> >> ### Existing code here(SQL, prepare, execute, etc) to >> ### insert rows into 2 different tables >> insert_rows; >> >> ### I want to add these next 2 lines in to this eval >> $rc = $my_obj->insert; ### my_obj is an object of ABC >> die "my_obj insert error" if $rc eq 'ERROR'; >> >> commit_transaction $dbh; >> }; >> if ($@) { >> rollback_transaction $dbh; >> # handle transaction error >> } >> >> >> >> On Friday, December 28, 2001, at 12:45 PM, Hardy Merrill wrote: >>> >>> I'd like to incorporate invoking that insert method into >>> another existing transaction, which basically looks like >>> this: >>> >>> >>> $dbh->{RaiseError} = 1; >>> $dbh->{AutoCommit} = 0; >>> eval { >>> >>> ### Existing code here(SQL, prepare, execute, etc) to >>> ### insert rows into 2 different tables >>> >>> ### I want to add these next 2 lines in to this eval >>> $rc = $my_obj->insert; ### my_obj is an object of ABC >>> die "my_obj insert error" if $rc eq 'ERROR'; >>> >>> $dbh->commit; >>> }; >>> if ($@) { >>> ### do rollback and handle transaction error here >>> } >>> >>> ------------------------------------------------------------- >>> >>> But it seems like it won't work - an eval in an eval - can >>> someone just confirm for me that this won't work? >>> >>> TIA. >>> >>> -- >>> Hardy Merrill >>> Mission Critical Linux, Inc. >>> http://www.missioncriticallinux.com >>> >>> >> >