Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re^3: RFC: Transactions.pm

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


in reply to Re^3: RFC: Transactions.pm (select function)
in thread RFC: Transactions.pm

transaction { select_handle($dhb); ... };

Not an option, because you need the handle before you begin the transaction. Won't begin the transaction inside the block, because that would allow stuff to be done outside the transaction while visually, it's in the transaction code block.

Simple to use modules have their limitations. The limitation of this one is that you shouldn't use nested transactions. I think that's acceptable in most cases.

I've only seen nested transactions being used to rollback multiple things. But it's easy to create a wrapper module for that:

package NeedsAName; sub new { return bless \@_, shift } sub AUTOLOAD { $_->$AUTOLOAD(@_) for @{+shift}; } package main; use Transactions; my $dbh1 = DBI->connect(...); my $dbh2 = DBI->connect(...); our $T = NeedsAName->new($dbh1, $dbh2); transaction { ... };

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

Replies are listed 'Best First'.
Re^5: RFC: Transactions.pm
by Aristotle (Chancellor) on Apr 28, 2003 at 11:25 UTC
    Won't begin the transaction inside the block, because that would allow stuff to be done outside the transaction while visually, it's in the transaction code block.
    By the same token you can calculate the question to 42 after you finish working with the handle but before you leave the transaction block. You're simply going to have to rely on discipline on that one. Perl always does so a bit more than other languages anyway.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-23 19:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found