On Mon, 4 Feb 2002, Rob Ransbottom wrote:

> Using DBI how do you explicitly start a transaction?
> I wish to explicitly 'begin work' to avoid the merging
> of separate transactions.
>
> DBI 1.13
> Postgres 7.1
> Perl 5.005

You should turn AutoCommit off when you create the database handle.  Tehn
you can do:

my $dbh = DBI->connect(
                      "DBI:Pg:dbname=$db",
                      $dbuser,
                      $dbpasswd,
                     { RaiseError => 1, AutoCommit => 0 }
                     )
        or die "Error connecting to data source $db: ", $DBI::errstr;
....

$dbh->begin_work;

....

$dbh->commit;

You might want to upgrade your DBI version.

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
Very few things happen at the right time, and the rest do not happen
at all.  The conscientious historian will correct these defects.
                -- Herodotus



Reply via email to