Skip to content

SIGNAL

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
-- signal an error
SIGNAL SQLSTATE '22012' SET MESSAGE_TEXT = 'An error has occurred!';
END;
Terminal window
ERROR 1644 (22012): An error has occurred!

In the given example, SIGNAL keyword is used to generate an error. The specific SQLSTATE value ‘22012’ is associated with division by zero. However, here it is used only for example purposes and doesn’t relate to any actual error scenario. If an exception occurs, the error defined in the SIGNAL statement gets triggered and the respective error message is displayed.