why is rollback necessary
am 05.05.2004 17:57:03 von Mayuran
Observe the following code :
$dbh->begin_work;
eval {
do_some_db_stuff();
$dbh->commit;
};
if ($@) {
eval { $dbh->rollback(); };
} else {
print "committed\n";
}
Is the $dbh->rollback() necessary? if $dbh->commit fails
then the data never got committed, so what is the point of
calling $dbh->rollback ? Is the transaction kept open
otherwise ?
Thanks
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: why is rollback necessary
am 05.05.2004 19:25:03 von Rudy Lippan
On Wed, 5 May 2004, mayuran wrote:
> Observe the following code :
>
> $dbh->begin_work;
>
> eval {
> do_some_db_stuff();
> $dbh->commit;
> };
>
> if ($@) {
> eval { $dbh->rollback(); };
> } else {
> print "committed\n";
> }
>
> Is the $dbh->rollback() necessary? if $dbh->commit fails
> then the data never got committed, so what is the point of
> calling $dbh->rollback ? Is the transaction kept open
> otherwise ?
Yes you still need to call rollback() because 1. It is not only the commit that
can fail in your example. 2. Think about this case.. $dbh->commit() fails but
later in your program you have a $dbh->commit that succeds.
Rudy
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: why is rollback necessary
am 05.05.2004 19:25:03 von Rudy Lippan
On Wed, 5 May 2004, mayuran wrote:
> Observe the following code :
>
> $dbh->begin_work;
>
> eval {
> do_some_db_stuff();
> $dbh->commit;
> };
>
> if ($@) {
> eval { $dbh->rollback(); };
> } else {
> print "committed\n";
> }
>
> Is the $dbh->rollback() necessary? if $dbh->commit fails
> then the data never got committed, so what is the point of
> calling $dbh->rollback ? Is the transaction kept open
> otherwise ?
Yes you still need to call rollback() because 1. It is not only the commit that
can fail in your example. 2. Think about this case.. $dbh->commit() fails but
later in your program you have a $dbh->commit that succeds.
Rudy
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org