-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE tda_sga_periodos_lectivos
-- TRIGGER AFTER DELETE
-- Tabla: sga_periodos_lectivos
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftda_sga_periodos_lectivos();
CREATE OR REPLACE FUNCTION ftda_sga_periodos_lectivos() 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_periodos_lectivos
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tda_sga_periodos_lectivos ON sga_periodos_lectivos RESTRICT;
CREATE TRIGGER tda_sga_periodos_lectivos 
    AFTER DELETE ON sga_periodos_lectivos
    FOR EACH ROW EXECUTE PROCEDURE ftda_sga_periodos_lectivos();
