-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE tda_sga_instituciones
-- TRIGGER AFTER DELETE
-- Tabla: sga_instituciones
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftda_sga_instituciones();
CREATE OR REPLACE FUNCTION ftda_sga_instituciones() 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_instituciones
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tda_sga_instituciones ON sga_instituciones RESTRICT;
CREATE TRIGGER tda_sga_instituciones 
    AFTER DELETE ON sga_instituciones
    FOR EACH ROW EXECUTE PROCEDURE ftda_sga_instituciones();
