|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: error handlers
Date: Jun 1 1999 10:55PM
John Gilmore-Baldwin writes:
> I'm having problems getting error handlers to work correctly. If I don't
> specify an error handler, the program works fine. If I do, and the error
> handler gets hit, my program dies immediately.
You probably want to set a message handler as well. The message
handler is called first for errors that happen in the server (SQL
errors, syntax errors, etc). The error handler will be called for
system errors (can't connect to the server, for example), and will
also be called *after* the message handler for server errors (that is
the reason for the
> if ($error != SYBESMSG)
> {
> print STDERR ("Sybase error: ", $error_msg, "\n");
> print STDERR ("OS Error: ", $os_error_msg, "\n") if defined
> ($os_error_msg);
> }
bit in the example error handler - only print these messages if the
error is NOT SYBEMSG - ie it's not an error message that comes from
the server.
Try to base your code off of the examples in sybutil.pl...
>
> sub SQLerrorHandler
> {
> my ($Database, $Severity, $Error, $OSerror, $ErrorMsg, $OSerrorMsg)
> = @_;
Note that $Database is not a string, it's the $database handle (ie the
connection) and may be undefined. It is possible that the
print "$Database"
is what's causing your script to exit.
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|