MySQL Forums
Forum List  »  Stored Procedures

How to catch SQL Exception Error number in MySQL 5.6
Posted by: Arun Mahajan
Date: December 01, 2019 07:17AM

Hi,
I have a MYSQL 5.6 version. In this version I want to capture the SQL Exception Error number and Error message.

In higher version you can use

GET DIAGNOSTICS CONDITION 1

And it works very well.

But for older version, I am failed to capture the Error Number.

Can you please help me do this.


As of now I am using the following code:

--
-- Cursor for SQL Exception Handler
--
DECLARE exit handler for sqlexception
BEGIN
SET msg = concat('{"status":"F", "msg":"There is some SQL exception. Please contact adminsitrator."}');
ROLLBACK;
END;


Regards,

Options: ReplyQuote


Subject
Views
Written By
Posted
How to catch SQL Exception Error number in MySQL 5.6
602
December 01, 2019 07:17AM


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.