in reply to Re: Having issues with DBI
in thread Having issues with DBI

You're not checking the return code from connect().

{RaiseError=>1} takes care of that.

Replies are listed 'Best First'.
Re^3: Having issues with DBI
by perrin (Chancellor) on Dec 11, 2008 at 16:09 UTC
    No, it doesn't. It only takes care of errors from methods called on the returned handle. You always have to check the return value of connect with or die $DBI::errstr.
      connect has died on RaiseError since 0.91
      use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:Oracle:xxxReal_databasename', 'xxxReal_use +r', 'bad_pasword', { PrintError => 0, RaiseError => 1, }); print "Got Here\n"; $dbh->disconnect(); OUTPUT: > ./tst DBI connect('XXXXX','XXXXX',...) failed: ORA-01017: invalid username/p +assword; logon denied (DBD ERROR: OCISessionBegin) at ./tst line 8
      Though you have to be careful about (so maybe it is best to add the "or die" regardless)...(and I say this because I've done nearly this, and not yet learned from my mistake):
      use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:Oracle:xxxReal_databasename', 'xxxReal_use +r', 'bad_pasword', { PrintError => 0, RaizeError => 1, }); print "Got Here\n"; $dbh->disconnect(); OUTPUT: > ./tst Got Here Can't call method "disconnect" on an undefined value at ./tst line 16.
        D'oh! You're right. That's what I get for using DBI for so long. I didn't notice this had changed.