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

    • Re: Error in installing perl DBI Module on sun 0s box
      ... I am getting below error messages,Could you please some one help ... Install your own build of Perl and then add DBI ...
      (perl.dbi.users)
    • Re: Perl 6 DBI API ideas
      ... Though I didn't raise my hand when you asked for people to contribute to a DBI module for Perl 6, I've had some ideas that I thought about sharing. ... I would also love to see some standardization on the driver names ("mysql" when it's normally written ... DBI is supposed to be query language agnostic, even if SQL is the most commonly used group of languages, and if a user can declare this explicitly, it saves the driver from having to guess what they were given, which might be ambiguous. ...
      (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)
    • 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)