MySQL Error Code: 1193. Unknown system variable

FrancescoN picture FrancescoN · Feb 4, 2013 · Viewed 35.7k times · Source

Ok so i'm working on triggers, and it tells me it(MySQL workbench 5.2) doesn't recognize this variable.
*Error Code: 1193. Unknown system variable error_msg_3*

I think it would be correct using it in a trigger, please help me

CREATE TRIGGER controlla_MaxCARDINALITA_INSERT
BEFORE INSERT ON SENTIERO__HA__TAPPA
FOR EACH ROW 
BEGIN

DECLARE max_cardinalita INTEGER;
DECLARE error_msg_3 CONDITION FOR SQLSTATE '99003';

SELECT COUNT(*) into max_cardinalita
FROM SENTIERO__HA__TAPPA
WHERE IDsentiero=NEW.IDsentiero;

IF max_cardinalita>=10 THEN
        SIGNAL error_msg_3;
        SET error_msg_3='INSERT: Il sentiero ha già il massimo numero di tappe consentito';

END IF;

END$$

EDIT ::

I tried this, and it seems working

DECLARE msg VARCHAR(255);
set msg = concat('MyTriggerError: Trying to insert a negative value in trigger_test: ');
signal sqlstate '45000' set message_text = msg;

Answer

hjpotter92 picture hjpotter92 · Feb 4, 2013

According to MySQL docs, the error #1193 occurs when you use wrong code for SQLSTATE.

Message: Unknown system variable %s

And, as you can see on the same page, the SQLSTATE 99003 is not defined.