create or replace procedure test_procproc4(t in number) as
type t_int is varray(10) of number;
type t_mint is varray(10) of t_int;
type t_tab is table of varchar2(50);
type t_mtab is table of t_tab;
type t_itab is table of t_int;
sint t_int := t_int(12);
smint t_mint := t_mint(sint); stab t_tab; smtab t_mtab; sitab t_itab;
tc integer := 10; tr integer := 9;
begin
sint := t_int();
stab := t_tab();
smint := t_mint();
smtab := t_mtab();
sitab := t_itab();
sint.extend(tc);
stab.extend(tc);
smint.extend(tc);
smtab.extend(tc);
sitab.extend(tc);
for i in 1 .. tc loop
sint(i) := 9;
stab(i) := '#@!tsadf2030071546';
smint(i) := t_int();
smtab(i) := t_tab();
sitab(i) := t_int();
smint(i).extend(tr);
smtab(i).extend(tr);
sitab(i).extend(tr);
for j in 1 .. tr loop
smint(i)(j) := 995;
smtab(i)(j) := 'easf';
sitab(i)(j) := 2868;
end loop;
end loop;
for i in 1 .. tc loop
execute immediate 'insert into test_4sp.test_proc(col_0)
values(:1)' using sint(1)t;
end loop;
end;
/
|
increasing the size of a collection (extend method)
to increase the size of a nested table or varray, use extend.
this procedure has three forms:
extend appends one null element to a collection.
extend(n) appends n null elements to a collection.
extend(n,i) appends n copies of the ith element to a collection.
you cannot use extend with index-by tables. you cannot use extend to add elements to an uninitialized collection. if you impose the not null constraint on a table or varray type, you cannot apply the first two forms of extend to collections of that type.
extend operates on the internal size of a collection, which includes any deleted elements. this refers to deleted elements after using delete(n), but not delete without parameters which completely removes all elements. if extend encounters deleted elements, it includes them in its tally. pl/sql keeps placeholders for deleted elements, so that you can re-create them by assigning new values.
阅读(1605) | 评论(0) | 转发(0) |