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

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


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_planes
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_planes ON sga_planes RESTRICT;
CREATE TRIGGER tib_sga_planes BEFORE INSERT ON sga_planes
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_planes();
