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

-- DROP FUNCTION ftib_sga_insc_cursada_log();
CREATE OR REPLACE FUNCTION ftib_sga_insc_cursada_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_cursada_log
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_insc_cursada_log  ON sga_insc_cursada_log RESTRICT;
CREATE TRIGGER tib_sga_insc_cursada_log BEFORE INSERT ON sga_insc_cursada_log
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_insc_cursada_log();
