Name

AutoCommit ( boolean)

Synopsis

If true, then database changes cannot be rolled back (undone). If false, then database changes automatically occur within a “transaction,” which must either be committed or rolled back using the commit or rollback methods.

Drivers should always default to AutoCommit mode (an unfortunate choice largely forced on the DBI by ODBC and JDBC conventions.)

Attempting to set AutoCommit to an unsupported value is a fatal error. This is an important feature of the DBI. Applications that need full transaction behavior can set $dbh->{AutoCommit} = 0 (or set AutoCommit to 0 via connect) without having to check that the value was assigned successfully.

For the purposes of this description, we can divide databases into three categories:

Databases that don’t support transactions at all.
Databases in which a transaction is always active.
Databases in which a transaction must be explicitly started ('BEGIN WORK').

Get Programming the Perl DBI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.