问题描述
示例3-22使用UPDATE插入整个多级集合
插入到region_tab (region_id,region_name) 值 (2,'americ');
声明
v_country nt_country_typ;
开始
v_country := nt_country_typ( country_typ (
'我们','美利坚合众国',nt_location_typ (
location_typ( 1500,“2011室内设计大道”,“99236”,“旧金山”,“加利福尼亚”),
location_typ(1600,'2007 Zagora St',' 50090 ',' 南不伦瑞克 ',' 新球衣 ');
更新区域 _ 标签r
设置r.国家 = v_country,其中r.region_id = 2;
结束;
/
以上是来自oracle doc。
Qn-是否可以在多级集合中进行批量插入操作。.. 类似于
我在1...
forall j in 1 ..
插入。.... 值tabtype(i).xxx,tabtype(j).yyy...
插入到region_tab (region_id,region_name) 值 (2,'americ');
声明
v_country nt_country_typ;
开始
v_country := nt_country_typ( country_typ (
'我们','美利坚合众国',nt_location_typ (
location_typ( 1500,“2011室内设计大道”,“99236”,“旧金山”,“加利福尼亚”),
location_typ(1600,'2007 Zagora St',' 50090 ',' 南不伦瑞克 ',' 新球衣 ');
更新区域 _ 标签r
设置r.国家 = v_country,其中r.region_id = 2;
结束;
/
以上是来自oracle doc。
Qn-是否可以在多级集合中进行批量插入操作。.. 类似于
我在1...
forall j in 1 ..
插入。.... 值tabtype(i).xxx,tabtype(j).yyy...
专家解答
并非如此,因为您要批量更新的内容是 * 行 *。
所以FORALL将工作正常,但它是为 (在你的情况下) NT_COUNTRY_TYP对象的多个实例。例如。
所以FORALL将工作正常,但它是为 (在你的情况下) NT_COUNTRY_TYP对象的多个实例。例如。
SQL> create or replace type obj_emp as object ( 2 empno int, 3 ename varchar2(20) 4 ); 5 / Type created. SQL> SQL> create or replace type nt_emp 2 as table of obj_emp; 3 / Type created. SQL> SQL> create table emp_obj_tab 2 ( dept int, 3 emp_list nt_emp 4 ) 5 nested table emp_list STORE AS emp_obj_tab_list 6 ; Table created. SQL> SQL> declare 2 type bulk_bind_array is table of nt_emp 3 index by pls_integer; 4 5 single_entry nt_emp := nt_emp(); 6 bulk_entries bulk_bind_array; 7 8 deptlist sys.odcinumberlist := sys.odcinumberlist(10,20,30,40); 9 begin 10 -- 11 -- one instance with multiple entries 12 -- 13 select obj_emp(empno,ename) 14 bulk collect into single_entry 15 from scott.emp; 16 17 -- 18 -- simulate multiple instances 19 -- 20 bulk_entries(1) := single_entry; 21 bulk_entries(2) := single_entry; 22 bulk_entries(3) := single_entry; 23 bulk_entries(4) := single_entry; 24 25 forall i in 1 .. bulk_entries.count 26 insert into emp_obj_tab values (deptlist(i), bulk_entries(i)); 27 end; 28 / PL/SQL procedure successfully completed. SQL>
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。