What is the mechanism to force the MySQL to throw an error within the stored procedure?
I have a procedure which call s another function:
PREPARE my_
Yes, there is: use the SIGNAL keyword.
You may use following stored procedure to emulate error-throwing:
CREATE PROCEDURE `raise`(`errno` BIGINT UNSIGNED, `message` VARCHAR(256))
BEGIN
SIGNAL SQLSTATE
'ERR0R'
SET
MESSAGE_TEXT = `message`,
MYSQL_ERRNO = `errno`;
END
Example:
CALL `raise`(1356, 'My Error Message');