Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: nsql error
Date: May 26 2000 2:46PM
David J Iannucci writes:
> I'm trying to use nsql to catch deadlocking errors,
> and referring to the Sybperl manual on Michael Peppler's
> web site. Unfortunately, for someone who's relatively
> new to this stuff, the description of the error handling
> facility of nsql is not entirely lucid.
> > The nsql() routine will maintain the success or failure
> > state in a variable $DB_ERROR, accessed by the method
> > of the same name, and a pair of Sybase message/error
> > handler routines are also provided which will use
> > $DB_ERROR for the Sybase messages and errors as well.
Usually what I do in this case is to look at the source and see if I
can figure it out. I realize that this may not always be easy,
especially if you are new to Sybase and/or perl, but it never hurts to
> I need to know:
> 1) What sort of values are stored in $DB_ERROR? Are
> they error code numbers, such as "1205" for deadlock
> victimization? The example code seems to suggest
> that they are English messages, but I'd like to confirm.
It's a string, so to check for a particular error (for which you know
the error number) you could do
$DB_ERROR =~ /Message: $errno\b/
which, in fact, is what nsql() does to detect deadlocks.
> 2) What is the "method of the same name"? Is there
> a routine called db_error()? If so, how do I use it?
my $the_error = $dbh->DB_ERROR;
print "Sybase error: $the_error\n";
Michael Peppler -||- Data Migrations Inc.
email@example.com -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: firstname.lastname@example.org