-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- TRIGGER BEFORE INSERT
-- Tabla: sga_periodos_lectivos
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftib_sga_periodos_lectivos();
CREATE OR REPLACE FUNCTION ftib_sga_periodos_lectivos() RETURNS TRIGGER AS $BODY$
  BEGIN
	   -- Genera un registro en la tabla de entidades..
       NEW.entidad := f_generar_entidad(300); -- periodos lectivos
       RETURN NEW;
  END;
$BODY$ LANGUAGE plpgsql;


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_periodos_lectivos
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_periodos_lectivos  ON sga_periodos_lectivos RESTRICT;;
CREATE TRIGGER tib_sga_periodos_lectivos BEFORE INSERT ON sga_periodos_lectivos
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_periodos_lectivos();
