Skip navigation links
/ / Up / Table of Contents

User Comments

Posted by Nicolas Bourré on January 30 2014 3:35pm[Delete] [Edit]

We wanted to create a generic procedure to throw errors where the error messages were kept in a table.

Since it is not possible to use a variable for the error code, we have done a workaround.

CREATE PROCEDURE throw_error (errorCode char(5))
BEGIN
SELECT CONCAT(errorCode, ' : ', message)
INTO _messageText
FROM error_messages
WHERE id = errorCode;

SIGNAL SQLSTATE '45001' SET MESSAGE_TEXT = _messageText
END

HTH

Top / / / Up / Table of Contents