On 1/4/07, Xavier Robin <[EMAIL PROTECTED]> wrote:
[...]

my $transaction = $c->model('MyAppDB')->storage;
$transaction->txn_begin;
eval {
    # Do some insertions with $c->model('MyAppDB::Table')->create()
};
if ($@) {
    $transaction->txn_rollback;
}
else {
    $transaction->txn_commit;
}


Fist of all, put your $transaction->txn_commit inside your eval{},
because the commit can fail too.

Note: I'm connecting to a PostgreSQL database with Autocommit on.

As long as you/DBIx::Class sends a BEGIN, your should be okey.


--
Kay Bærulfsen

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to