I have 3 tables :
portees : represent an electricity line with several columns (por_cur, equipment A, equipment B, ..., iqu_cur, examine)
cab_portees : represent a specific equipment on the lines (there can be many instance of those equipment on one line), Columns (id, por_cur (foreign key from portees), ..., iqu_cur)
indice_qualite : represent 1 attribut of one of the other two table which is considered important data. Columns (table_name, attribut_name, ...,iqu_cur, examine)
We check the data in table portees and cab_portees to be sure its correct, when one line is checked we update portees.examine to '1'. I want to make a trigger to auto update the table indice_qualite : put all the equipment from the table to examine = '1'.
I have trouble getting the right syntax, here is what I have :
create or replace trigger PORTEES_EXAMINE_TRIGGER
AFTER UPDATE ON PORTEES
FOR EACH ROW
BEGIN
if :new.EXAMINE != :old.EXAMINE then
UPDATE (SELECT INDICE_QUALITE.EXAMINE FROM
INDICE_QUALITE, PORTEES
WHERE PORTEES.IQU_CUR = INDICE_QUALITE.IQU_CUR
AND PORTEES.IQU_CUR = :old.IQU_CUR
UNION
SELECT INDICE_QUALITE.EXAMINE FROM
INDICE_QUALITE, CAB_PORTEES
WHERE CAB_PORTEES.IQU_CUR = INDICE_QUALITE.IQU_CUR
AND CAB_PORTEES.POR_CUR = :old.POR_CUR)
SET INDICE_QUALITE.EXAMINE = :new.EXAMINE;
end if;
END PORTEES_EXAMINE_TRIGGER;
Any ideas ?