sql >> Base de Datos >  >> RDS >> Mysql

Se está manejando la excepción de acceso al controlador de excepciones de MySQL

Se parece a RESIGNAL es lo que buscas.

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`resig` $$
CREATE PROCEDURE `test`.`resig` ()
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
  SELECT 'I executed something before throwing the error' as `this_works`;
  RESIGNAL;
END;

SELECT foo FROM bar WHERE baz = 0;

END $$

DELIMITER ;


mysql> call resig();
+------------------------------------------------+
| this_works                                     |
+------------------------------------------------+
| I executed something before throwing the error |
+------------------------------------------------+
1 row in set (0.00 sec)

ERROR 1054 (42S22): Unknown column 'foo' in 'field list'

mysql>