Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

DBD::mysql does not return errorstring

by Skeeve (Vicar)
on May 12, 2014 at 09:34 UTC ( #1085765=perlquestion: print w/ replies, xml ) Need Help??
Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

I have this code, which fails to report an error when I deliberately use a non existing database tabel:

use DBI; # Load the DBI module ### Perform the connection using the Oracle driver my $dbh = DBI->connect( "dbi:mysql:MYDB:localhost:3306", "NYUSER", "MY +PASS", { PrintError => 0, RaiseError => 0 } ) or die "Can't connect to the database: $DBI::errstr\n"; ### Prepare a SQL statement for execution my $sth = $dbh->prepare( "UPDATE user_settingsX set `language`=? WHERE + `username` = ?" ) or die "Can't prepare SQL statement: $DBI::errstr\n"; ### Execute the statement in the database $sth->execute("fr", "admin") or die "Can't execute SQL statement: ",$sth->errstr,"\n"; ## I also tried: "Can't execute SQL statement: $DBI::errstr\n"; ### Disconnect from the database $dbh->disconnect or warn "Error disconnecting: $DBI::errstr\n"; exit;

I would expect the an error message telling me that the tabel "user_settingsX" does not exist, but the errstr is undef.

I'm using:

  • Windows 7
  • strawberryperl 5, version 18, subversion 1 (v5.18.1) built for MSWin32-x64-multi-thread
  • DBD::mysql 4.023
  • DBI 1.628

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Comment on DBD::mysql does not return errorstring
Select or Download Code
Re: DBD::mysql does not return errorstring
by Skeeve (Vicar) on May 12, 2014 at 10:21 UTC

    Again I reply to myself ;)

    So for reference purposes: Update to a newer Version of strawberry perl (and so to a newer DBD::mysql) resolved the issue.

    I'm now using

    • Windows 7
    • strawberryperl 5, version 18, subversion 2 (v5.18.2) built for MSWin32-x64-multi-thread
    • DBD::mysql 4.027
    • DBI 1.631

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re: DBD::mysql does not return errorstring
by leslie (Pilgrim) on May 12, 2014 at 11:10 UTC

    Hi,

    You should enable any one of the automatic error checking. Below I have enable warning

    PrintError => 1, # To enable warnings RaiseError => 0 # To enable die

    If both RaiseError and PrintError are enabled, an error will cause warn( ) and die( ) to be executed sequentially.

      That does not help as:

      1. I did not want to print diagnostics in my production code but handle the error in my code. Note: The posted code is a small example code. It is not my actual production code.
      2. But even with diagnostics on, there was no error reported.

      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Reaped: Re: DBD::mysql does not return errorstring
by NodeReaper (Curate) on May 12, 2014 at 11:10 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1085765]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (17)
As of 2014-07-22 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (119 votes), past polls