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.
阅读(1619) | 评论(0) | 转发(0) |