Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: message_handler
Date: Jan 21 1998 7:56PM

Naveen_Rajavasireddy@ACML.COM wrote:
> 1) Installed the message_handler in my program.
> 2) Insert SQL statement 1 for table A
> Before the execution of next statement, I create a deadlock situation by
> running a program in a
> different session.
> 3) Insert SQL statement 2 for table B
> 4) The above command becomes a deadlock victim and fails.
> 5) Program loops back and starts from step 2 on looking at the 1205 message
> My problem is that after the fail on step 3, my variables from the message
> handler are still that of deadlock
> even though, I insert into the database successfully.

How do you check for the 1205 error in the main body of your code?

I've usually done something like:

if($dbh->dbsqlexec() == FAIL) {
	if( $error = 1205 ) {
		goto try_again;

Of course, you could also do something a little more fancy if
you have sybperl 2.09:

$dbh = new Sybase::DBlib user, pwd, server, undef, {LastError => 0 };

The in the message handler, do

$dbh->{LastError} = $msg_no;

(the $dbh is the first param to the message handler).

Then you can check $dbh->{LastError} when dbsqlexec or dbresults
fail, without the need for a global variable.

This does not work in 2.08 and before because the $dbh parameter that
is passed to message_handler is a copy of the original $dbh.

Michael Peppler       -||-  Data Migrations Inc.  -||-