> Sorry to interfere so late in this thread, but
> 
> if the commit() is placed here, won't it be always executed, because 
> there are no die statements which stop code execution upon errors 
> before ? Shouldn't committing be made dependent of the value of $@ 
> like
> 
> if ($@) {
>       warn "Transaction aborted because $@";
>       $dbh->rollback; # undo the incomplete changes
>      # add other application on-error-clean-up code here
> }
> else {
> 
>       $dbh->commit();
> }

Actually there is a very good reason for the code being represented the way
it is within the DBI docs as Peter posted earlier.

The question you must ask of the code represented above is, "What happens if
commit fails?".

The purpose is to raise an error and thus cause eval to fail before the
commit is reached (last statement), if so then the condition of failure for
the eval is to issue a $dbh->rollback.

I guess it's the difference between "Do all the work but if the work fails,
go back to the start" and "Do all of the work, if the work fails go back to
the start, but if the work was successful *really* do all the work."

I'm out of breath just saying that let alone coding it.

Neil

> 
> 
> Bodo
> 
> [EMAIL PROTECTED]
> 
> Dr. med. Bodo Eing
> Institut fuer Medizinische Mikrobiologie
> Klinische Virologie
> v.-Stauffenbergstr. 36
> 48151 Muenster
> Germany
> 
> Phone: ++49 251 7793 111 Fax: ++49 251 7793-104
> 

__________________________________________________________________________
Please Note :
Only  the intended recipient is authorised to access or use this e-mail.  If
you are not the intended recipient,
please delete this e-mail and notify the sender immediately.   The contents
of this e-mail are the writer's 
opinion and are not necessarily endorsed by the Gunz Companies unless
expressly stated.

We use virus scanning software but exclude all liability for viruses or
similar in any attachment.


Reply via email to