MySQL Forums
Forum List  »  Stored Procedures

Re: Capture error messages using DECLARE statements
Posted by: Roland Bouman
Date: June 29, 2005 03:54AM


When you want to stick with pure SP's there's apparently is no other way than to write a specific handler for each and every SQLSTATE that you anticipate, at least for now.

Right now, MySQL does not seem to implement a @@ERROR (SQL Server T-SQL) global variable or a SQLCODE/SQLERRM (Oracle PL/SQL) pair of globals, which is what you need, right?

It does seem likely to me that this is bound to be corrected quite soon, especially because this kind of information (SQLSTATE) is available to external programs/libraries communicating with the server.

Mean while, would it be possible to write a UDF which returns the value of SQLSTATE?

Interestingly, ISO 9075:1999 does not address this issue either, at least not explicitly. It does specify a GET DIAGNOSTICS statement (iso 9075:1999 ch19: Diagnostics management) wich supplies a generic mechanism for obtaining all kinds of diagnostics (not just errors).

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.