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

-- DROP FUNCTION ftib_sga_insc_examen_log();
CREATE OR REPLACE FUNCTION ftib_sga_insc_examen_log() RETURNS TRIGGER AS $BODY$
  BEGIN
     -- Genera un nro de Transaccion
     IF NEW.nro_transaccion_log IS NULL THEN
        NEW.nro_transaccion_log := f_nro_transaccion();
     END IF;   
     RETURN NEW;
  END;
$BODY$ LANGUAGE plpgsql;


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_insc_examen_log
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_insc_examen_log  ON sga_insc_examen_log RESTRICT;
CREATE TRIGGER tib_sga_insc_examen_log BEFORE INSERT ON sga_insc_examen_log
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_insc_examen_log();
