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

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


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_reinscripciones
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_reinscripciones  ON sga_reinscripciones RESTRICT;
CREATE TRIGGER tib_sga_reinscripciones BEFORE INSERT ON sga_reinscripciones
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_reinscripciones();
