Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Try/catch syntax

How can I not get the right syntax for a simple try/catch? Do I have to do anything more?

All I get is error 1064...

BEGIN TRY
SELECT * FROM NonExistentTable;
END TRY

BEGIN CATCH
SELECT * FROM ExistingTable;
END CATCH;
GO

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRY
SELECT * FROM NonExistentTable' at line 1 

Thanks

like image 939
Pandara Avatar asked Oct 24 '25 02:10

Pandara


1 Answers

MySQL doesn't have TRY/CATCH functionality. You can use handlers.

like image 140
HoneyBadger Avatar answered Oct 26 '25 17:10

HoneyBadger