SIGNAL error_condition [SET error_property [, error_property] ...] error_condition: SQLSTATE [VALUE] 'sqlstate_value' | condition_name error_property: error_property_name = <error_property_value> error_property_name: CLASS_ORIGIN | SUBCLASS_ORIGIN | MESSAGE_TEXT | MYSQL_ERRNO | CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | CATALOG_NAME | SCHEMA_NAME | TABLE_NAME | COLUMN_NAME | CURSOR_NAME CREATE PROCEDURE test_error(x INT) BEGIN DECLARE errno SMALLINT UNSIGNED DEFAULT 31001; SET @errmsg = 'Hello, world!'; IF x = 1 THEN SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO = errno, MESSAGE_TEXT = @errmsg; ELSE SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO = errno, MESSAGE_TEXT = _utf8'Hello, world!'; END IF; END; CREATE PROCEDURE test_error(n INT) BEGIN DECLARE `too_big` CONDITION FOR SQLSTATE '45000'; IF n > 10 THEN SIGNAL `too_big`; END IF; END; CREATE PROCEDURE test_error() BEGIN DECLARE EXIT HANDLER FOR 1146 BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Temporary tables not found; did you call init() procedure?'; END; -- this will produce a 1146 error SELECT `c` FROM `temptab`; END;
SQL Справочник v0.05 © 2007-2025 Igor Salnikov aka SunDoctor