Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: DBI error and $@

by notsoevil (Pilgrim)
on Dec 06, 2001 at 23:12 UTC ( #130031=note: print w/replies, xml ) Need Help??

in reply to Re: DBI error and $@
in thread DBI error and $@

There is no other code. :)

There are no other warnings. :)

I know it should print something. However it is not, hence my confusion.

I'd really just like an explanation of the examples in the Perl DBI book and/or Randal's article on why they used the format:

eval { $dbh->do($statement); $dbh->commit(); } if ($@) { $dbh->rollback(); die $@; }
I believe my sample code is an example of this (save the $dbh->rollback, but that isn't the issue). The examples check $@ and then die with it, after a rollback. If $@ isn't being printed (interpolated into my warn string), how does the conditional execute? If it is executing (and hence doing a rollback) when $@ does not have a printable value, this may affect my transactions.

Or am I just completely batty?

Jeremiah 49:32 - And their camels shall be a booty. . .

Replies are listed 'Best First'.
(jeffa) Re: DBI error and $@
by jeffa (Bishop) on Dec 06, 2001 at 23:28 UTC
    Hmmm ... using mysql v3.23.36, Perl 5.6.0, and DBI v1.20:
    # connect with RaiseError set to true eval { $dbh->do('UPDATE a SET x = y'); $dbh->commit(); }; if ($@) { warn "flurg!: $@"; warn "flurg!: ", $dbh->errstr(); }
    DBD::mysql::db do failed: Table 'mysql.a' doesn't exist at ./test_db_e line 20. flurg!: DBD::mysql::db do failed: Table 'mysql.a' doesn't exist at ./t line 20. flurg!: Table 'mysql.a' doesn't exist at ./ line 25.


    (the triplet paradiddle)
      That first warning is due to not turning PrintError off when turning RaiseError on (which many, including me, often neglect to do).

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2023-12-08 19:16 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (37 votes). Check out past polls.