1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| CREATE TRIGGER GENA01BI
BEFORE INSERT ON GENA01P0
REFERENCING NEW AS NEW
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
DECLARE SQLSTATE CHAR(5);
DECLARE
WCOMPTEUR2 INT DEFAULT 0;
IF NEW.CEANRG IS NOT NULL OR
NEW.CCODRG IS NOT NULL
THEN
SELECT 1 INTO WCOMPTEUR2 FROM GENA01P0 WHERE <-- Ici l'appel sur la table GENA01P0 ne marche pas dans le trigger d'elle meme
CENVIR = NEW.CENVIR AND CEANAR = NEW.CEANRG AND
CCODVA = NEW.CCODRG AND BCPRIX = 1 ;
IF WCOMPTEUR2 = 0
THEN
SIGNAL SQLSTATE '38000' SET MESSAGE_TEXT='GEN0009';
END IF;
END IF; |