CREATE OR ALTER TRIGGER CODIGOS_BI FOR CODIGOS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.NRO_CODIGO IS NULL) THEN BEGIN
    NEW.NRO_CODIGO = GEN_ID(ORDEN_GEN, 1);
  END
  NEW.INACTIVO = FALSE;
END
