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: Jamie Belanger <jamie_belanger at globalcrossing dot com>
Subject: RE: Trapping Sybase errors...
Date: Feb 10 2000 2:00PM

As far as I know, just CTlib, but that's the only one I ever use. ;)
 

Jamie Belanger 
Sys Admin, Global Crossing 
(319) 298-1489 or ext. 489 
 

 

-----Original Message-----
From: Troy Taylor [mailto:ttaylor@JCLLC.COM]
Sent: Wednesday, February 09, 2000 5:06 PM
To: SybPerl Discussion List
Subject: RE: Trapping Sybase errors...


Is this just for CTlib or also for DBlib?
 
Thanks!
 
Troy

-----Original Message-----
From: Jamie Belanger [mailto:jamie_belanger@globalcrossing.com]
Sent: Wednesday, February 09, 2000 3:47 PM
To: SybPerl Discussion List
Subject: RE: Trapping Sybase errors...



You add client and server callbacks... Here's an example of how to do it: 
----------------------------------------------------------------- 

#Place this somewhere at the top of your script 
#error handling (stolen from those who came before) 
ct_callback(CS_CLIENTMSG_CB, \&msg_cb); 
ct_callback(CS_SERVERMSG_CB, "srv_cb"); 

################################################################## 
# error handling sub routines (stolen from those who came before) 
################################################################## 

sub msg_cb 
{ 
        my($layer, $origin, $severity, $number, $msg, $osmsg) = @_; 

        printf STDERR "\nOpen Client Message: (In msg_cb)\n"; 
        printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld)",
$layer, $origin; 
        printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n", $severity,
$number; 
        printf STDERR "Message String: %s\n", $msg; 
        if (defined($osmsg)) 
        { 
                printf STDERR "Operating System Error: %s\n", $osmsg; 
        } 
        CS_SUCCEED; 
} 

sub srv_cb 
{ 
        my($cmd, $number, $severity, $state, $line, $server, $proc, $msg) =
@_; 
        printf STDERR "\nServer message: (In srv_cb)\n"; 
        printf STDERR "Message number: %ld, Severity %ld, ", $number,
$severity; 
        printf STDERR "State %ld, Line %ld\n", $state, $line; 
        
        if (defined($server)) 
        { 
                printf STDERR "Server '%s'\n", $server; 
        } 

        if (defined($proc)) 
        { 
                printf STDERR "Procedure '%s'\n", $proc; 
        } 
        printf STDERR "Message String: %s\n", $msg; CS_SUCCEED; 
} 


Jamie Belanger 
Sys Admin, Global Crossing 
(319) 298-1489 or ext. 489 
 



-----Original Message----- 
From: Fuerte, Hector BGI SF [ mailto:Hector.Fuerte@barclaysglobal.com
 ] 
Sent: Wednesday, February 09, 2000 4:26 PM 
To: SybPerl Discussion List 
Subject: Trapping Sybase errors... 


Hi! 
  
How do you trap this sql error in Perl: 
  
Msg 2601, Level 14, State 3: 
Server 'SA_SBU', Line 1: 
Attempt to insert duplicate key row in object 't_web_xing_stats_hist' with 
unique index 'XPKt_web_xing_stats_hist' 
Command has been aborted. 
(0 rows affected) 
  
thanks. 
Hector