in reply to Re^2: DBI selectall_arrayref
in thread DBI selectall_arrayref

My point is that some error checking needs to be done, and none was being done. If the method is the RaiseError flag, so be it. But something's got to be in place or you'll never know if the DB is connecting, if the statement handles are being prepared and executed, and so on. The irony is that I discussed the more common Perl idiom (or die ...) instead of the more DBI'ish idiom (RaiseError).


Dave

Replies are listed 'Best First'.
Re^4: DBI selectall_arrayref
by jeffa (Bishop) on Sep 03, 2004 at 02:00 UTC

    ... or you'll never know if the DB is connecting

    Technically speaking, well yes, you could know if the DB is connecting without causing the script to die. If connect() fails, a warning via STDERR is emitted but your script still runs. By specifying {RaiseError => 1}, DBI will, by default, "throw" a die for you, but you can still see why the connect failed without having to explicitly or die $DBI::errstr or use {RaiseError => 1}.

    Finally, telling a "newbie" to go back and add error checking usually results in statements like "I just want to get it to work." That's why i recommend {RaiseError => 1} up front, you only need to add one line of code for error checking across the board. I'm just nitpicking Dave ... you and your point for some error checking are gold. :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)