-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE tda_planes_versiones
-- TRIGGER AFTER DELETE
-- Tabla: sga_planes_versiones
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftda_sga_propuestas();
CREATE OR REPLACE FUNCTION ftda_sga_planes_versiones() RETURNS TRIGGER AS $BODY$
  BEGIN
       -- Borro el registro en la tabla de entidades..
       DELETE FROM sga_g3entidades WHERE entidad = OLD.entidad;
       RETURN OLD;
  END;
$BODY$ LANGUAGE plpgsql;


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE sobre sga_planes_versiones
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tda_sga_planes_versiones ON sga_planes_versiones RESTRICT;
CREATE TRIGGER tda_sga_planes_versiones 
    AFTER DELETE ON sga_planes_versiones
    FOR EACH ROW EXECUTE PROCEDURE ftda_sga_planes_versiones();
