samedi 4 juin 2016

If statement inside Trigger not working SQL(Oracle)

So, my goal is to create a trigger that checks if the number you are tring to enter on the table (NR_RECIBO) is the table Doc_cabecalho with the DOC_TIPO = 4

CREATE OR REPLACE TRIGGER ValidaRecibo
BEFORE INSERT ON Recibo
FOR EACH ROW
DECLARE val NUMBER;
BEGIN
SELECT COUNT(*) INTO val FROM Doc_cabecalho WHERE (TIPO_DOC = 4 AND NR_DOCUMENTO = :NEW.NR_RECIBO);
IF val = 0 THEN (-20502, ' Only from department 6 ');
END IF;
END ValidaRecibo;
/

Yet, this raises the following error:

4/25 PLS-00103: Encountered the symbol "," when expecting one of the following: * & = - + < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like like2 like4 likec as between || member submultiset

Help, please

Aucun commentaire:

Enregistrer un commentaire