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: =?iso-8859-1?Q?Pochet_Fr=E9d=E9ric?= <Frederic dot Pochet at cockerill-sambre dot com>
Subject: RE: SybPerl-DBlib question..
Date: Jan 27 1999 7:39AM

try:
	if @@error <> 0 ...


here is an extract of sybase help:
	The @@error global variable is commonly used to check the error
status of the most recently executed batch in the current user session.
@@error contains 0 if the last transaction succeeded; otherwise @@error
contains the last error number generated by the system. A statement such
as if @@error != 0 followed by return causes an exit on error. 
	Every Transact-SQL statement, including print statements and if
tests, resets @@error, so the status check must immediately follow the
batch whose success is in question.


==========================================
Frederic Pochet
DBA DB Distribuees

Cockerill Sambre

*
Rue Vieille Fosse
B-4400 Flemalle
Belgium

*  +32 4 236 20 71
*   +32 4 236 21 00
*  frederic.pochet@cockerill-sambre.com
==========================================

> ----------
> From: 	Narasayya Immid[SMTP:narasan@yahoo.com]
> Reply To: 	SYBPERL-L@listproc.net
> Sent: 	mercredi 27 janvier 1999 6:27
> To: 	SybPerl Discussion List
> Subject: 	SybPerl-DBlib question..
> 
> 
> 
> I am using SybPerl-DBlib. I was trying to update a table in a
> transaction. If the update is failed thru' underlying trigger, how can
> I capture the error code and message raised by the trigger? How do I
> stop the program flow?
> Any help is greatly appreciated.
> 
> - Thanks in advance.
> -----------------------------------------------------
> 
>    
> $dbh= Sybase::DBlib->dblogin("user","pwd","SYBSERVER");
>  $dbh->dbuse("dbname");
>  $dbh->dbcmd("begin tran \n
>               update ...
>               set ...
>               where ....
>  
>               if(\@\@rowcount != 1)
>               begin
>                  rollback transaction
>               end \n
> 
>               Another update...
> 
>               if(\@\@rowcount != 1)
>               begin
>                  rollback transaction
>               end \n
> 
>               commit tran \n
> 
>               ");
>    $dbh->dbsqlexec;
>    while($dbh->dbresults !=NO_MORE_RESULTS)
>    {   
>        while(%dbdata=$dbh->dbnextrow(1))
>        {          
>        }
>    }
>    $dbh->dbclose();
> 
> 
> 
> 
> 
> 
> 
> 
> _________________________________________________________
> DO YOU YAHOO!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>