使用 sqlldr 插入具有批处理 ID 的行



我能够使用 sqlldr 将行插入表中,而无需担心。我想将文件的所有行标记为唯一编号,以便我可以将它们视为一个批次。我尝试将"my_db_seq.nextval"作为批处理 ID。但它不符合我的目的。

因此,请告知如何在使用 sqlldr 加载时为文件的整组行创建唯一的批处理 ID。

将你对序列的调用包装在这样的函数中:

create or replace function get_batch_id return integer is
x exception;
-- ORA-08002: sequence %s.CURRVAL is not yet defined in this session
pragma exception_init (x, -8002);
begin
return my_db_seq.currval;
exception
when x then 
return my_db_seq.nextval;
end;

然后从控制文件调用它:

...
batch_id "get_batch_id()"
...

来自这篇文章:https://www.orafaq.com/forum/t/187236/。

最新更新