[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Autocommmit?



I always leave Autocommit on.  Then in the part of my script that
requires transactional processing, I manually issue something like
$dbh->do("BEGIN TRANSACTION") then when I've executed all the SQL
statements I need to be done together I use $dbh->do("COMMIT").  But I
suppose I should be switching autocommit on and off when I need it, and
then using $dbh->commit.  I think the problem I ran into with that is
the DBD driver didn't think the database supported transactions.  So I
had to do the transaction stuff manually.

-Ryan

> -----Original Message-----
> From: Jay Hannah [mailto:jhannah@omnihotels.com] 
> Sent: Tuesday, February 21, 2006 1:10 PM
> To: omaha-pm@pm.org
> Subject: Re: [Omaha.pm] Autocommmit?
> 
> > Is there a best-practices approach to going one way or the 
> other? I'm 
> > trying to think of a situation where I wouldn't want an autocommit.
> 
> Well, you can't AutoCommit any time you want to control 
> transactions, which would be any time you're doing multiple, 
> related SQL operations.
> e.g.: Only do these 5 SQL statements IF all 5 of them work. 
> If any of them fail, don't do ANY. In those cases, you need 
> to explicitly control commit's/rollback's in your program at 
> the appropriate times.
> 
> In general I vote for AutoCommit off. I'd much rather 
> accidentally NOT commit something when my program is wrong 
> than accidentally commit something I didn't mean to commit 
> yet. The opposite is also arguable.
> 
> j
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm@pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>