PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Error handling with DBLib
Date: Mar 19 1998 3:49PM

Milan Mikic wrote:
> 
> Dear all,
> 
> Is there a good example of how to handle errors while using sybperl through
> DBlib ? A piece of code that can be reused would be excellent.

Errors from the execution of queries are returned to the
client (script) in the message_handler. You can write your
own or use the one provided in the sybutil.pl file (it should 
be installed in lib/perl5/site_perl).

In general, you should do the following:

$dbh->dbcmd($sql);
if($dbh->dbsqlexec != SUCCEED) {
    error, return
}

while(($ret = $dbh->dbresults) != NO_MORE_RESULTS) {
    if($ret == FAIL) {
	error.
	either call dbcancel() and return
	or just do a next;
    }
    while(@dat = $dbh->dbnextrow) {
 	....
    }
}

Additional details on how the message handler works is available in the
sybase docs for DBlibrary.

Hope this helps,

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com