DBI error checking not working

From: patrickg (pat_at_patmail.com)
Date: 02/11/05

  • Next message: Mark D Andrews: "RE: finding and inserting"
    Date: Fri, 11 Feb 2005 16:39:29 GMT
    
    

    Hey all - new to Perl and DBI, so just trying to get an understanding of
    things. I copied some sample code from the Perl DBI book in the error
    checking section, but I can't seem to get any of the error messages that I
    expect. Instead, the program crashes and I get the popup box stating " Perl
    Command Line Interpreter has encountered a problem and needs to close.". Can
    someone tell me why none of these error messages are are being displayed
    when I deliberately make a typo (ie. bad password, malformed SQL, etc) to
    cause an error? (I've tried all the combinations of setting the PrintError
    and RaiseError).

    use strict;
    use DBI;

    my $dbh = DBI->connect( 'dbi:Oracle:orcl',
                            'scott',
                            'tiger',
                            { RaiseError => 0,
                              PrintError => 0}
                          )|| die "Database connection not made: $DBI::errstr";

    my $sth;
    my $sql;
    my ($obj1, $obj2);

      $sql = qq{SELECT table_name, column_name
                FROM user_tab_cols};

      $sth = $dbh->prepare($sql) or die "Can't prepare: ", $dbh->errstr;
      $sth->execute() or die "Can't execute: ", $dbh->errstr;
      $sth->bind_columns( undef, \$obj1, \$obj2 );

      while( $sth->fetch() ) {
        print "$obj1\t$obj2\n";
      }
      $sth->finish();

    TIA!
    patrick


  • Next message: Mark D Andrews: "RE: finding and inserting"

    Relevant Pages

    • Problem of DBI build
      ... I installed Oracle Application Server 4.0.8.2 included perl module. ... I need to installe DBI and DBD::Oracle module. ... You can install them any time after installing the DBI. ... line 318: error 1705: Function prototypes are an ANSI feature. ...
      (perl.dbi.users)
    • Problem of DBI build
      ... I installed Oracle Application Server 4.0.8.2 included perl module. ... I need to installe DBI and DBD::Oracle module. ... You can install them any time after installing the DBI. ... line 318: error 1705: Function prototypes are an ANSI feature. ...
      (perl.dbi.users)
    • Re: use of DBI; I am getting multiple error messages mixed in with the correct output.
      ... T> expected a mature library like DBI to behave like this. ... I learned plenty about the perl side of things from her posts. ... closely represent the SQL idea of a null. ... trivially easy to perform bulk loads using the DB's particular ...
      (comp.lang.perl.misc)
    • Re: DBD::Informix and SIGBUS in perl
      ... use DBI; ... > My program is a CGI script in perl, which provides web-access to a database ... assigned to a DBD::Informix database handle. ... > LANGUAGE (unset) ...
      (perl.dbi.users)
    • RE: Perl DBI Urgent
      ... I thought you said you are on perl 5.8 not perl 5.6? ... DBI is failing so there is no ... If you have a c compiler and just need to install perl modules get any ... eventually compile DBI and DBD Oracle. ...
      (perl.dbi.users)