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

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


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_comisiones
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_comisiones  ON sga_comisiones RESTRICT;;
CREATE TRIGGER tib_sga_comisiones 
    BEFORE INSERT ON sga_comisiones
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_comisiones();
