in reply to perl w/ DBI connectiong to MSSQL, not reporting SQL server trigger errors

Set RaiseError to true on the connect, wrap the whole thing in an eval block, and check $@ after the block. I'd bet it is failing where you are not checking for failure. RaiseError will check all DBI calls for you :-)

Update: and use strict (super search here for tutorials and meditations).

  • Comment on Re: perl w/ DBI connectiong to MSSQL, not reporting SQL server trigger errors

Replies are listed 'Best First'.
Re^2: perl w/ DBI connectiong to MSSQL, not reporting SQL server trigger errors
by legato (Monk) on Jan 06, 2005 at 19:07 UTC

    For debugging purposes, it's almost better not to wrap it in eval. $dbh->{RaiseError}=1 will cause each DBI method to die with the generated error message, which by default will print to STDERR.

    Anima Legato
    .oO all things connect through the motion of the mind

      You are correct, depending on whether or not you want the rest of the script to continue. But rather than setting $dbh->{RaiseError} = 1 I usually prefer adding a {RaiseError => 1} argument to the connect, so that even connect errors are caught by RaiseError.
        After using eval around my DBI code, when the page loads, i get this following error: bind_col: column 2 is not a valid column (1..1) at /var/www/cgi-bin/archtmltest.pl line 306, line 8641. It's weird though. It only happens the first time i visit the page. Once I refresh it once, it's fine. And everytime i visit the page after that it's fine. It's only the very first time i visit the page that error shows up. Any ideas why? Thanks