in reply to DBI error and $@

This doesn't make sense, you say $@ is not being printed, but it must be set to something or else you wouldn't even be executing that warn statement. Are you getting a warning from somewhere else in the script (and are all of your warnings as descriptive as this one? :)

Update: When I'm in doubt about variables that must be there, but don't appear to be, then I resort to something like:

my $hex = unpack("H*", $@); warn "Warning: [$@] [$hex]";
You've got the latest versions of DBI & DBD??

Replies are listed 'Best First'.
Re: Re: DBI error and $@
by notsoevil (Pilgrim) on Dec 06, 2001 at 23:12 UTC
    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?

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

      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(); }
      yielded:
      DBD::mysql::db do failed: Table 'mysql.a' doesn't exist at ./test_db_e +val.pl line 20. flurg!: DBD::mysql::db do failed: Table 'mysql.a' doesn't exist at ./t +est_db_eval.pl line 20. flurg!: Table 'mysql.a' doesn't exist at ./test_db_eval.pl line 25.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      F--F--F--F--F--F--F--F--
      (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).