Search code examples
mysqlsqlsyntaxtry-catchmysql-error-1064

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


Solution

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