in reply to RFC: Transactions.pm
+-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(64) | YES | | NULL | | | description | varchar(64) | YES | | NULL | | +-------------+-------------+------+-----+---------+-------+and the following client code:
I honestly expected there to be no output ... shouldn't a rollback cause all 'inserted' data to be 'undone'?use strict; use warnings; use DBI; my $dbh = DBI->connect( ... ); use transactions $dbh; $dbh->do('delete from foo'); transaction { for (1..10) { my $sth = $dbh->prepare('insert into foo values(?,?,?)'); $sth->execute($_, chr(ord('a')+$_), chr(ord('z')-$_)); rollback if $_ == 5; } }; print map "@$_\n", @{$dbh->selectall_arrayref('select * from foo')}; $dbh->disconnect; __END__ results: 1 b y 2 c x 3 d w 4 e v 5 f u
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: RFC: transactions.pm
by chromatic (Archbishop) on Apr 27, 2003 at 20:01 UTC | |
|
Re: (jeffa) Re: RFC: transactions.pm
by Juerd (Abbot) on Apr 27, 2003 at 20:03 UTC |