Procédures interbase
Table DELETERHCONTRAT
CREATE TABLE DELETERHCONTRAT (
RECID DOM_INTEGER,
RECDATE DOM_DATE,
RECUSER DOM_CODE,
RECPERID DOM_INTEGER,
RECCTRID DOM_INTEGER,
RECMATRICULE DOM_INTEGER,
RECNUMFULL DOM_VCHAR10 COLLATE NONE);
Trigger
CREATE TRIGGER RHCONTRAT_AD FOR RHCONTRAT ACTIVE
AFTER DELETE POSITION 1
AS
BEGIN
INSERT INTO DELETERHCONTRAT ( RECID,RECDATE,RECUSER,RECPERID,RECMATRICULE,RECCTRID,RECNUMFULL)
VALUES (0, "now",'',old.ctrperid,old.ctrpermatricule,old.ctrid,old.ctrnumfull);
END
Exception
CREATE EXCEPTION SUPCONTRAT 'Suppression impossible : Virement existant'
Trigger
CREATE TRIGGER RHCONTRAT_BD FOR RHCONTRAT
BEFORE DELETE POSITION 0
AS
BEGIN
if (exists(
select * from rhibanitem where itbidctr=old.ctrid ))
then exception supcontrat;
END