|
|
sybperl-l Archive
Up Prev Next
From: "Wechsler, Steven M" <WechslerSM at bernstein dot com>
Subject: DBLib sql method & error handling
Date: Jun 3 1998 6:12PM
How can you trap SQL errors when using the sql method? Are the two
mutually exclusive, or am I doing it wrong?
Here's what I'm doing:
#! /usr/local/bin/perl5
use Sybase::DBlib;
[get $server, $password, $dbname]
$handle = new Sybase::DBlib "sa", $password, $server ||
die "Unable to open connection to $server\n";
$handle->dbuse($dbname) || die "Unable to USE $dbname\n";
dberrhandle("error_handler");
[do some non-Sybase-related processing]
$handle->sql("drop index some_non_existent_index");
sub error_handler
{
my ($db, $severity, $error, $os_error, $error_msg, $os_error_msg) =
@_;
if ($error == 3701) {
print "Index was already dropped - continuing...";
$sqlerr = 0;
INT_CANCEL;
} else {
print "SQL Error $error: $error_msg";
$sqlerr = $error;
INT_EXIT;
}
}
I was expecting the error handler to see error 3701, which is "Cannot
drop the index '%s', because it doesn't exist in the system catalogs.";
however, what I always see is error 20018, "General SQL Server error:
Check messages from the SQL Server." I suspect this is the error I
would get no matter what the problem was.
What am I doing wrong?
Thanks,
Steve
--
Steven Wechsler/Sybase DBA/Sanford C. Bernstein & Co., Inc.
WechslerSM@bernstein.com
"Never underestimate the power of human stupidity" - Lazarus Long
Support the Anti-SPAM amendment: http://www.cauce.org
|