-1

我正在从 Cursor-B 为光标-A 中的每条记录批量收集记录,有没有办法将此 Cursor-B 数据附加到表类型,以便我可以一次将其插入表中?

  • 我无法组合 cursor-A 和 Cursor-B SQL。
  • 我知道 BULK COLLECT 永远不会附加到集合中,但有什么方法可以实现我所提到的。
4

1 回答 1

3

您可以使用 a 在单个操作中组合集合MULTISET UNION

declare
    --Collection types.
    type type_rec is record(a number);
    type type_nt is table of type_rec;

    --Collection variables.
    v_var1 type_nt;
    v_var2 type_nt;
    v_both type_nt;
begin
    --Get the data.
    select 1 bulk collect into v_var1 from dual connect by level <= 1000;
    select 1 bulk collect into v_var2 from dual connect by level <= 1000;

    --Combine the two nested tables together in a single operation.
    v_both := v_var1 multiset union all v_var2;
end;
/
于 2017-12-15T02:36:47.177 回答