Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在oracle中将批量获取的行附加到表类型?_Oracle_Plsql_Bulk Collect - Fatal编程技术网

如何在oracle中将批量获取的行附加到表类型?

如何在oracle中将批量获取的行附加到表类型?,oracle,plsql,bulk-collect,Oracle,Plsql,Bulk Collect,我正在从Cursor-B为Cursor-A中的每个记录大容量收集记录,是否有任何方法将Cursor-B数据附加到表类型,以便我可以立即将其插入表中 我不能将cursor-A和cursor-B结合使用 我知道批量收集从来没有附加到收集,但有任何方法来实现我所说的 您可以使用以下方法在单个操作中组合集合: 声明 --集合类型。 类型记录是记录(一个数字); 类型nt是类型rec的表格; --集合变量。 v_var1类型\u nt; v_var2型nt; v_两种类型\u nt; 开始 --获取数据

我正在从Cursor-B为Cursor-A中的每个记录大容量收集记录,是否有任何方法将Cursor-B数据附加到表类型,以便我可以立即将其插入表中

  • 我不能将cursor-A和cursor-B结合使用
  • 我知道批量收集从来没有附加到收集,但有任何方法来实现我所说的

您可以使用以下方法在单个操作中组合集合:

声明
--集合类型。
类型记录是记录(一个数字);
类型nt是类型rec的表格;
--集合变量。
v_var1类型\u nt;
v_var2型nt;
v_两种类型\u nt;
开始
--获取数据。

从dual connect by level中选择1 bulk collect to v_var1不是直接选择,但这样做的目的只是暗示数据类型是兼容的。如果是这种情况,您也许可以将查询与联合结合起来。发布集合的游标和类型定义。这可能有助于提供一个啤酒答案。但是如果光标-a有100行呢?我需要合并100个嵌套表吗?我认为这是不可行的。100行可以放在一个嵌套表中,并且可以在一个步骤中组合。很抱歉,如果我把您弄糊涂了,那么要求是为cursor中的每个记录调用cursor-B-A@Dunbay在cursor-A循环中,可以将cursor-B批量收集到一个集合中,然后将该数据与其他集合合并。也许添加一些伪代码可以帮助我理解这个问题。
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;
/