[python-sybase] Need Help w/ Stored Procedures Error Handling
Tony Burger
anburger76 at hotmail.com
Tue, 10 Dec 2002 22:54:40 -0500
Question regarding error handling when using stored procedures. If I have a
procedure usp_delete_database_data which takes 3 parameters @dbID int,
@error_no int output and @error_desc varchar(255) output, and I call this
procedure using something as follows:
try:
varTest =
c.callproc('usp_delete_database_data',{'@dbID':varDBID,'@error_no':varErrorNo,'@error_desc':varErrorDesc})
except Sybase.DatabaseError:
print "Unable to delete database data for database_id"
else:
print "Success"
Is there any way to capture the error_no and error_desc return variables? If
I simply call the procedure using c.callproc outside of a try block and an
SQL error occurs within the procedure, Python raises the
Sybase.DatabaseError and the script blows up. When inside the try block the
varErrorNo and varErrorDesc are not populated. I'm assuming this is because
the c.callproc() doesn't really run successfully because of the
Sybase.DatabaseError that is occurring? The procedure error that I am
testing is a simple 2601 duplicate key insert error. I need the c.callproc()
to run successfully and then be able to capture the error_no and error_desc
outputs. Perhaps I'm missing something? Thanks
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail