jeudi 14 mars 2013

Créer un trigger sous oracle

-- -- Trigeer de mise à jour des formation et module -- create or replace TRIGGER "UPDATE_MODULE_FORMATION" AFTER INSERT OR UPDATE ON ACTION_FORMATION FOR EACH ROW WHEN (new.id_action_formation>0) DECLARE v_id_action_formation integer; v_id_action_formation_parent integer; BEGIN v_id_action_formation:= :New.id_action_formation; v_id_action_formation_parent:= :New.id_action_parent; IF v_id_action_formation_parent is not null THEN update action_formation set formation = (SELECT libelle FROM action_formation where id_action_formation=v_id_action_formation_parent) where id_action_formation=v_id_action_formation; update action_formation set module = (SELECT libelle FROM action_formation where id_action_formation=v_id_action_formation_parent) where id_action_formation=v_id_action_formation; else update action_formation set formation = libelle where id_action_formation=v_id_action_formation; update action_formation set module = null where id_action_formation=v_id_action_formation; end if; END;

Aucun commentaire: