-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE tda_sga_elementos
-- TRIGGER AFTER DELETE
-- Tabla: sga_elementos
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftda_sga_elementos();
CREATE OR REPLACE FUNCTION ftda_sga_elementos() 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_elementos
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tda_sga_elementos ON sga_elementos RESTRICT;
CREATE TRIGGER tda_sga_elementos 
    AFTER DELETE ON sga_elementos
    FOR EACH ROW EXECUTE PROCEDURE ftda_sga_elementos();
