Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: RFC: Transactions.pm

by crenz (Priest)
on Apr 28, 2003 at 11:15 UTC ( [id://253650]=note: print w/replies, xml ) Need Help??


in reply to RFC: Transactions.pm

Personally, I don't like the package global. I'd prefer something like

my $dbh = DBI->connect(...); transaction $dbh, { for (1..10) { my $sth = $dbh->prepare(...); $sth->execute() or rollback; } };

or even

transaction($dbh) { # code };

to make it look like a for block. I have no idea how to make that work, though.

Also, an additional idea would be to catch die's in the handler and make them execute rollback (which would make your transactions a bit like exceptions).

Replies are listed 'Best First'.
Re: Re: RFC: Transactions.pm
by Juerd (Abbot) on Apr 28, 2003 at 11:17 UTC

    I'd prefer something like transaction $dbh, {

    I would prefer that too! But Perl 5's prototypes don't allow that syntax. It requires the "sub" keyword then. I'm not sure if I want that.

    Also, an additional idea would be to catch die's in the handler and make them execute rollback.

    Already does that, and has always done that :)

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://253650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found