[Mastering-perl] Chapter 5 and transactions

Philippe Bruhat BooK philippe.bruhat at free.fr
Wed Jan 3 16:46:06 EST 2007


Hi,

I chapter 5, you write:

I don't have to actually write to the database for every
C<INSERT>. I'll do it all at once when I C<COMMIT>.

# dbi-profile-sqlite-transaction.pl
$dbh->do( "BEGIN TRANSACTION" );
foreach my $index ( 0 .. $#array )
{
$insert->execute( $index, $array[$index] );
}
$dbh->do( "COMMIT" );

Why not show an example using the { AutoCommit => 0 } paramater or the
begin_work() method coupled with the commit() method?

--
Philippe "BooK" Bruhat

In the contest between simplicity and silence, silence hasn't got a prayer.
(Moral from Groo The Wanderer #15 (Epic))


More information about the Mastering-perl mailing list