in reply to Database Record Order

This is totally unrelated to your question, but do yourself a big favor and start replacing:
$DBH = DBI->connect( $DSN, $USER, $PASS ) || die "Connect Error: $DBI: +:errstr\n";
With
$DBH = DBI->connect( $DSN, $USER, $PASS, { RaiseError => 1} );
and enjoy the luxury of never needing to worry about placing
|| die $DBH->errstr;
after every $DBH method call again. ;)

UPDATE:
Thanks for catching that typo 3dan. :)

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)

Replies are listed 'Best First'.
Re: Re: Database Record Order
by edan (Curate) on Dec 31, 2003 at 06:48 UTC

    Good advice. But you might want to replace:

    $DBH = DBI->connect( $DSN, $USER, $PASS, { RaiserError => 1} );

    With this:

    $DBH = DBI->connect( $DSN, $USER, $PASS, { RaiseError => 1} );

    ;)

    --
    3dan

Re: Re: Database Record Order
by thor (Priest) on Dec 31, 2003 at 13:40 UTC
    I got the impression that you still had to check for errors on the connect, after which if the RaiseError attribute was set further errors on that database handle would be fatal. From the documentation (emphasis added):
    If the connect fails (see below), it returns "undef" and sets both $DBI::err and $DBI::errstr. (It does not set $!, etc.) You should generally test the return status of "connect" and "print $DBI::errstr" if it has failed.
    Don't get me wrong: I'd love it if DBI behaved in the manner in which you describe. However, I'm willing to do the error checking once if it does not. :-)

    thor

      Actually, if you try to connect() with bogus credentials with either RaiseError turned on or off, your script is going to die regardless of whether you add or die $DBI::errstr or not. I don't bother adding it, because i just don't have to. If the connect fails, my program will die (just run the debugger and see for yourself).

      In other words, DBI does behave in the manner in which i described. But you can still be explicitly redundant, if you want. ;)

      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)
      
        I ran a quick test right before I posted the original, and it had the behavior that you described. What I didn't know is if it was DBI behavior, or the behavior of my specific database driver. As a result of your postings, I'll be changing my style. Thanks!

        thor

Re: Re: Database Record Order
by vbrtrmn (Pilgrim) on Dec 30, 2003 at 22:34 UTC
    Thanks jeffa!!

    --
    paul