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: bruno dot georges at barclayscapital dot com
Subject: RE: Can't catch error when sp fails
Date: Aug 9 1999 7:37AM

Thanks Mikael,

In the code I added a call to ct_callback and I can catch it when it dies 
in $@ I get the message "spFeedSAPCostCodeInfo failed Failed at
/opt/dev/gsp/bin/GSPDb.pm line 89.

I didn't use yet dbresults() .
Also the stored proc doesn't exist on the server, I did call an unexisting
sp on purpose to see how I could capture the error.
Next step is so call the right sp but to force the sp to fail and to see how
I can catch it in a way the support team can locate the error easily.

Thanks for any directions.

Bruno

sub feedSAPQCostCode{
        my($dbh) = @_;
        ct_callback(CS_SERVERMSG_CB, \&srvMsgCallBack);
        # id is an output parameter in the sp
        my ( $dbq, $resType, $id, $rc); 
        eval{
		...
                ($dbh->ct_execute($dbq) == CS_SUCCEED) or die
"spFeedSAPCostCodeInfo failed";
  		...
              }
        };
        panic($@) if $@;
}

sub srvMsgCallBack {

...

}

> -----Original Message-----
> From:	Michael Peppler [SMTP:mpeppler@peppler.org]
> Sent:	08 August 1999 22:08
> To:	SybPerl Discussion List
> Subject:	Re: Can't catch error when sp fails
> 
> The error will be raised in the dbresults() calls, not in dbsqlexec()
> because the SQL you execute returns more than one result set.
> 
> Michael
> 
> bruno.georges@barclayscapital.com wrote:
> > 
> > Hi
> > 
> > I am writing a script to log errors to syslog when a stroed procedures
> > fails.
> > 
> > In the example below I have the script returning the following error:
> >         Server message:
> >         Message number: 2812, Severity 16, State 5, Line 1
> >         Server 'oplss0026'
> >         Message String: Stored procedure 'spFeedSAPCostCodeInfo' not
> found.
> >         Specify owner.objectname or use sp_help to check whether the
> object
> > exists (sp_help may produce lots of output).
> > 
> > But I am not catching the error using eval .
> > 
> > Any idea.
> > 
> > Regards,
> > Bruno
> > 
> > Here the sub my script calls:
> > 
> > sub feedSAPQCostCode{
> >         my($dbh) = @_;
> > 
> >         my ( $dbq, $resType, $rc);
> > 
> >         # build query
> >         $dbq =  "exec spFeedSAPCostCodeInfo \n";
> >         eval{
> >                 $dbh->ct_sql("use $conf{'dbname'}");
> > 
> >                 ($dbh->ct_execute($dbq) == CS_SUCCEED) or die  "Cannot
> > execute query";
> > 
> >                 while(($rc= $dbh->ct_results($resType)) == CS_SUCCEED){
> >                         next unless $dbh->ct_fetchable($resType);
> >                         while(@dat= $dbh->ct_fetch()){}
> >                 }
> >         };
> >         # I want to raise an alert if the sp fails
> >         panic($@) if $@;
> > }
> > 
> >
> --------------------------------------------------------------------------
> ------------
> > For more information about Barclays Capital, please
> > visit our web site at http://www.barcap.com.
> > 
> > Internet communications are not secure and therefore the Barclays Group
> > does not accept legal responsibility for the contents of this message.
> > Any views or opinions presented are solely those of the author and do
> > not necessarily represent those of the Barclays Group unless otherwise
> > specifically stated.
> > 
> >
> --------------------------------------------------------------------------
> ------------
--------------------------------------------------------------------------------------
For more information about Barclays Capital, please
visit our web site at http://www.barcap.com.

Internet communications are not secure and therefore the Barclays Group
does not accept legal responsibility for the contents of this message.
Any views or opinions presented are solely those of the author and do 
not necessarily represent those of the Barclays Group unless otherwise 
specifically stated.

--------------------------------------------------------------------------------------