in reply to Re: How to safely test if a database handle is capable of transactions?
in thread How to safely test if a database handle is capable of transactions?

fmerges,
Where is encapsulation being broken?
$dbh->{AutoCommit} = 0;
The DBI is a tied interface and you are not really breaking encapsulation by doing this. This is a perfectly acceptable way of doing business with this module - just see the docs.

You did indirectly answer the OP's question (begin_work). According to the docs - If the driver does not support transactions then when begin_work attempts to set AutoCommit off the driver will trigger a fatal error. You just need to work it a bit differently since the OP wants to know if transactions are supported prior to trying a transaction. This means checking the actual contents of $@ rather than just seeing if it is set.

Cheers - L~R

  • Comment on Re^2: How to safely test if a database handle is capable of transactions?
  • Download Code