in reply to Re^2: SQL INSERTs don't work
in thread SQL INSERTs don't work

RaiseError does not apply to the connect. You should always check the return value of the connect() call, period.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^4: SQL INSERTs don't work
by thor (Priest) on Nov 08, 2004 at 21:59 UTC
    Do you have docs to back it up? Here's a snippet from Programming the Perl DBI that seems germane:
    #!/usr/bin/perl -w # # ch04/error/ex2: Small example using automatic error handling with # RaiseError, i.e., the program will abort upon detection # of any errors. use DBI; # Load the DBI module my ($dbh, $sth, @row); ### Perform the connection using the Oracle driver $dbh = DBI->connect( "dbi:Oracle:archaeo", "username", "password" , { PrintError => 0, ### Don't report errors via warn( ) RaiseError => 1 ### Do report errors via die( ) } ); ### Prepare a SQL statement for execution $sth = $dbh->prepare( "SELECT * FROM megaliths" ); ### Execute the statement in the database $sth->execute( ); ### Retrieve the returned rows of data while ( @row = $sth->fetchrow_array( ) ) { print "Row: @row\n"; } ### Disconnect from the database $dbh->disconnect( ); exit;
    Seems odd that they'd leave the error checking off of the connect when they do it in the section called "manual error checking". I'd honestly like to know if my programming style is wrong. I read once that RaiseError applied to the connect and have been leaving the 'or die "Couldn't connect..."' off ever since.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      My comments came from personal experience, in the fact that I've seen connect() fail and not die with RaiseError set to true. In reading the source code, it seems that the code you posted should work correctly. I'd prefer to see tbunce or someone similar comment on this thread and give an authoritative answer.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.