|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Trapping Errors with Sybperl
Date: Aug 7 2000 3:10PM
Chen, Charley writes:
> Hi,
>
> I'm new to the list and new to sybperl. So this question may seem stupid.
> I am trying to fix a perl script that is wrapper for isql. However it
> doesn't seem to trap errors properly. For example if I pass in a simple
> sql:
> Select 1/0
This error is flagged in the msg handler as error 3607.
You can verify this with the following little script:
#!/usr/local/bin/perl
use Sybase::DBlib;
dbmsghandle(sub { print "msg: @_\n"; });
dberrhandle(sub { print "err: @_\n"; });
$dbh = new Sybase::DBlib 'sa';
$dbh->dbcmd("select 1/0");
$dbh->dbsqlexec;
$dbh->dbresults;
$dbh->dbnextrow;
which outputs:
troll (8:07AM):47 > perl ~/tmp/err.pl
msg: 5701 2 0 Changed database context to 'master'. 3
msg: 5703 1 0 Changed language setting to 'us_english'. 3
msg: Sybase::DBlib=HASH(0x81684b8) 3607 0 0 Divide by zero occurred. 1
The reason it does not show when using the handlers in sybutil.pl is
that the "severity" value appears to be 0, which seems strange. The
handler in sybutil.pl ignores all messages with severity < 10.
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
|