Someone else reported this a while ago and I'll look into it before the next release.
Tim.
On Fri, Feb 01, 2002 at 09:02:22AM -0800, Gavin Sherlock wrote:
> Hmmm. You think I'd be able to use the || die, but the following:
>
> eval {
>
> $dbh = DBI->connect("dbi:Oracles:$database", $user, $pass, {
> RaiseError=>1, AutoCommit=>0 })
>
> || die "No database connection was made";
>
> };
>
> does not die (ie it doesn't populate $@). But if on the very next line, I
> put:
>
> print $dbh, "\n";
>
> then running in -w mode, I get:
>
> Use of uninitialized value in print at ......
>
> If however, if I put in a test to see if $dbh is defined, it clearly says
> that $dbh is not defined:
>
> eval {
>
> $dbh = DBI->connect("dbi:Oracles:$database", $user, $pass, { RaiseError=>1,
>AutoCommit=>0 });
>
> };
>
> if ($@) {
>
> &$errorSub($database, "Cannot connect to the oracle server : $database",
>$DBI::errstr);
>
> }elsif (!defined($dbh)){ # we failed to get a connection, but it wasn't fatal
>
> &$errorSub($database, "Cannot connect to the oracle server : $database");
>
> }
>
> because the elsif part is executed. Now I am perplexed!
>
>
> Cheers,
> Gavin
> ___________________________________________________________
>
> Gavin Sherlock
> Dept. of Genetics
> Center for Clinical Sciences Research
> 269 Campus Drive,
> Room 2255b,
> Stanford,
> CA 94305-5166
>
> Tel: 650 498 6012
> Fax: 650 723 7016
>
> On Fri, 1 Feb 2002, Sterin, Ilya wrote:
>
> > How about trying || die on the connect and $DBI::errstr. I wonder if the
> > RaiseError is set after a certain operations that's failing.
> >
> > Ilya
> >
> > -----Original Message-----
> > From: Gavin Sherlock
> > To: [EMAIL PROTECTED]
> > Sent: 2/1/02 9:32 AM
> > Subject: connect question RE: RaiseError
> >
> > Hi,
> > If I:
> >
> > $dbh = DBI->connect("dbi:Oracle:$database", $user, $pass, {
> > RaiseError=>1,
> > AutoCommit=>0 });
> >
> > will DBI issue a die if connection fails? I thought it should (and I
> > think it has in the past, if $database is unavailable), but I found that
> > if I accidentally put:
> >
> > dbi:Oracles:$database
> >
> > instead (note misspelling) then while $dbh is indeed undefined, no die
> > occurs, and my eval, which I have wrapping the connection, does not trap
> > anything. In addition, no value is set for $DBI::errstr. Is this
> > expected behaviour?
> >
> > I'm using perl 5.6.1 with DBI 1.20, DBD::Oracle 1.12 and running on 64
> > bit
> > Solaris 8,
> >
> > Cheers,
> > Gavin
> > ___________________________________________________________
> >
> > Gavin Sherlock
> > Dept. of Genetics
> > Center for Clinical Sciences Research
> > 269 Campus Drive,
> > Room 2255b,
> > Stanford,
> > CA 94305-5166
> >
> > Tel: 650 498 6012
> > Fax: 650 723 7016
> >
>