Bug #16371 HOW TO GET SQLSTATE
Submitted: 11 Jan 2006 12:32 Modified: 4 Oct 2008 18:11
Reporter: lucols lucols Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version:5.0 OS:Any (all)
Assigned to: CPU Architecture:Any

[11 Jan 2006 12:32] lucols lucols
Description:
when exception occur in a procedure , i want to process  it , and i want to know what happen  whitch  the mysql server  sent. example, i Define exception handler:
DECLARE EXIT HANDLER FOR SQLEXCEPTION  
BEGIN
    ROLLBACK; 
    call opts_process_log (errorCode,  'errorMessave' );
    COMMIT;
END;

But , i can't get the errorCode in procedure . 
I know mysql provider 'show errors' or other application's api (mysql_error()), but why not provider  like this 'select get_error()' or other way to get the error code for sql? 
who can tell me how to get the error in procedure when the error occur,please?  
 If no this way, It's a bug, big bug.

How to repeat:
for mail : lucols@163.com thanks.
[11 Jan 2006 12:47] Valeriy Kravchuk
Thank you for a problem report. Yes, something similar to Oracle's SQLCODE and SQLERRM functions will be useful for handlers. But I do not think it is a serious bug - as a workaround, you may also declare several specific handlers for different SQLSTATEs you expect, and the default one for all others. One "universal" handler that logs everything is not so good idea, anyway.

So, I mark this report a verified and reasonable feature request.
[12 Jan 2006 8:07] lucols lucols
thanks for you repeat,.Kravchuk . But realy no any way to get the errorCode in procedure ? If use like the 'CASE statement' to catch error, I dont think it is a good way Becaus when you debug the procedure , you could't know what would be happen . Popularly, error happen, i want to log the error  code and message , then rollback the transaction , otherwise, I realy did not know what's the error. 
 Any body has met the problem and have the good way to deal with it, tell me please.
[7 Sep 2006 13:54] Valeriy Kravchuk
Duplicate of bug #11660. Work on that bug is already started, according to PeterG.
[12 Aug 2009 20:54] Rajeev Ranjan
Are we able to get the details of Error? Any solution for this bug so far?

Thanks
Rajeev R