Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to catch SQL Exception Error number in MySQL 5.6

Status
Not open for further replies.

Arun Mahajan

Programmer
Nov 29, 2019
2
IN
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,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top