MySQL Forums
Forum List  »  Stored Procedures

Capture error messages using DECLARE statements
Posted by: Cornelius Sybrandy
Date: June 27, 2005 09:45AM

Hello,

I'm writing a stored procedure and I would like to enhance it's error handling capabilities. Currently, it will do a rollback on any error condition. However, I would like to be able to log the message to an error log table. How do I capture the error message? I thought about using the SHOW ERRORS command, but how would I get the error message into a variable? I've seen nothing in the documentation so far that helps.

Just as an FYI, here's what I would like to be able to do:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
**Get error message**;
INSERT INTO error_log (error_code, error_message) VALUES (error_code_var, error_msg_var);
END;

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.