How to throw an error in MySql procedure? How to throw an error in MySql procedure? mysql mysql

How to throw an error in MySql procedure?


You may use following stored procedure to emulate error-throwing:

CREATE PROCEDURE `raise`(`errno` BIGINT UNSIGNED, `message` VARCHAR(256))BEGINSIGNAL SQLSTATE    'ERR0R'SET    MESSAGE_TEXT = `message`,    MYSQL_ERRNO = `errno`;END

Example:

CALL `raise`(1356, 'My Error Message');