|
|
sybperl-l Archive
Up Prev Next
From: David C Worenklein <dcw at gcm dot com>
Subject: Re: How to find out when you're killed because of a deadlock?
Date: Apr 9 1998 1:35PM
The answer is in the Sybase manuals, if you know where to look.
Create your Sybase handle thus:
my $db = new Sybase::DBlib($USER, $PWD, $SERVER, $APPNAME, {DEADLOCK => 0});
Use this message handler:
sub SybMsgHandler {
my ($db, $message, $state, $severity, $text, $server, $procedure, $line) = @_;
if ( $message == 1205 ) { # Deadlock
$db->{DEADLOCK} = 1;
}
0;
}
When you do a query, first set $db->{DEADLOCK}=0, then do your query,
then check $db->{DEADLOCK}.
Note that this doesn't work before SybPerl 2.09. In earlier vesions,
you have to use $DEADLOCK{$db->{dbproc}} instead of $db->{DEADLOCK}.
|