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 peppler dot org>
Subject: RE: Trapping Sybase errors...
Date: Feb 10 2000 3:06PM

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

For DBlib you should look at sybutil.pl, which is part of the sybperl
distribution (in the lib/ directory).

Michael

 > 
 > -----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 
 >   
 > 
 > 
 > 
 > 
 > RE: Trapping Sybase errors...
 > 
 > 
 > 
 > 
As far > as I know, just CTlib, but that's the only one I ever use. > ;)
>
 
>

J size=2>amie B face=Arial size=2>elanger
face=Arial>Sys size=2> A size=2>dmin, color=#008000 face=Arial>Global face=Arial size=2> C face=Arial size=2>rossing
(319) > 298-1489 or > ext. 489
<mailto: > jamie_belanger@globalcrossing.com>

>
 
>
>
size=2>-----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?
>
class=940120523-09022000> 
>
class=940120523-09022000>Thanks!
>
 
>
class=940120523-09022000>Troy
>
>
size=2>-----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:
size=2>----------------------------------------------------------------- >

>

#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");

>

size=2>################################################################## >
# error handling sub routines (stolen from those who came > before)
size=2>################################################################## >

>

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; >
        } >
        size=2>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))
        size=2>{
        >         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
size=2><mailto: jamie_belanger@globalcrossing.com>



>

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


>

Hi!
 
size=2>How do you trap this sql error in Perl:
size=2> 
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'
size=2>Command has been aborted.
(0 rows > affected)
 
size=2>thanks.
Hector
size=2> 

-- 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