Is there a MySQL feature like SQL Server 2005 TRY / CATCH?

I am considering migrating a database from Sql Server 2005 to MySQL.

I'm used to using the SQL Server TRY / CATCH block in stored procedures.

Does MySQL have something similar, or will I be forced to return to my old school "check the error return after each statement and release the" goto if failed "programming style?

+6
mysql
source share
2 answers

You can declare handlers for certain errors.

+6
source share

There is no try / catch in MySQL as far as I know. Here is something that can help with stored procedure errors:

DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT 'SQLException invoked'; 

Source: http://www.mysqltutorial.org/mysql-error-handling-in-stored-procedures/

0
source share

All Articles