|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Trapping errors from dblogin
Date: Mar 9 1998 4:48PM
W. Phillip Moore wrote:
>
> If one has an message handler routine installed *before* calling
> dblogin, then libsybdb will indeed call this handler when dblogin()
> fails.
>
> However, the usual means of reading the error string uses code like
> the following (taken from the nsql_message_handler() routine):
>
> foreach $row ( split(/\n/,Sybase::DBlib::dbstrcpy($db)) ) {
> $DB_ERROR .= sprintf ("%5d", $lineno ++) . "> $row\n";
> }
>
> However, calling dbstrcpy produces a fatal error if the login fails:
Right - because dblogin() returns 'undef' when the login fails, so
there's no dbproc to read the dbcmd buffer from (which wouldn't
make sense on a dblogin() call anyway.
I'd simply put an if($db) around the whole thing:
if($db) {
foreach $row ( split(/\n/,Sybase::DBlib::dbstrcpy($db)) ) {
$DB_ERROR .= sprintf ("%5d", $lineno ++) . "> $row\n";
}
}
Maybe not as elegant as trapping the dbstrcpy() call in an
eval(), but it's just my style, I guess.
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
|