
DBIx::Class::Manual::SQLHackers::Transactions - DBIx::Class for SQL Hackers - DELETE

BEGIN;
SELECT users.id, users.username FROM users WHERE id = 1;
UPDATE users SET username = 'fred' WHERE id = 1;
COMMIT;
To create a transaction, put all your changes inside a coderef, and pass it to the txn_do method on the Schema object. Transactions can also be safely nested, in which case all but the top level transaction blocks become noops.
my $schema = MyDatabase::Schema->connect('dbi:SQLite:my.db');
$schema->txn_do( sub {
my $user = $schema->resultset('User')->find({ id => 1 });
die if(!$user);
$user->update({ username => 'fred' });
} );