Robin Houston <[EMAIL PROTECTED]> writes:
> On Wed, Mar 28, 2001 at 08:08:00PM +0100, Robin Szemeti wrote:
> > On Wed, 28 Mar 2001, Paul Makepeace wrote:
> > > Can Perl do distributed database transactions?
> >
> > probably .. simple multi threaded app, fork a few child processes,
> > establish the odd DBI connection, execute a query each return when the
> > last child is reaped ... 100 lines?
>
> I think the key word in Paul's question was "transactions".
> In other words, you have more than one database, possibly
> in different physical (and network) locations, and you need
> to perform a transaction - an _atomic_ transaction - across
> several of them.
>
> No partial failure allowed, it has to either succeed completely
> or fail completely.
eval {
$fulfillment_dbh->do("BEGIN TRANSACTION");
$payment_dbh->do("BEGIN TRANSACTION");
do_the_payment_thing($payment_dbh);
do_the_fulfillment_thing($fulfillment_dbh);
$payment_dbh->do("COMMIT");
$fulfillment_dbh->do("COMMIT");
}
if $@ {
$fulfillment_dbh->do("ROLLBACK");
$payment_dbh->do("ROLLBACK");
}
Hmm... not quite sure what happens if either of the COMMITs fail. And
I'd bemused as to how Java would handle it too...
--
Piers