Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> add elements to a varray
How I can add elements DYNAMICALY to a Varray in oracle 8.17? I'm
trying to create a varray from varchar2 with delimiters.
Create type StrList as VARRAY(100) of VARCHAR2(2000);
function List(pItems IN VARCHAR2, pDelimit IN VARCHAR2) return StrList
IS
vItemsCount PLS_INTEGER;
vList StrList := StrList();
i PLS_INTEGER := 1;
vItems VARCHAR2(30000);
begin
vItems := pItems
WHILE i < vItemsCount LOOP
vList(i) := SUBSTR(vItems, 1 ,INSTR( vItems, pDelimit ) -1 );
vItems := SUBSTR( vItems, INSTR( vItems, pDelimit ) + 1);
END LOOP;
vList(i) := vItems;
return vlist;
END List;
Note pItems is "VarChar2DelimitVarChar2pDelimitVarChar2DelimitVarChar2" vItemsCount return the number of delimeters in pItems. Inthis case: 3
Error ORA-06533: Subscript beyond count on vList(i) := SUBSTR(vItems, 1 ,INSTR( vItems, pDelimit) -1 );
If I wrote vList := StringList(VarChar2, VarChar2,VarChar2); its ok,
no errors.
When I try to add elements one at a time I get errors. Is oracle that
inflexible when dealing with
varray or I'm doing something wrong? I thought that varry can contain
a varying number of elements. If so I should be able to add elements
dynamically? What the use of Extend()!.
Thanks Received on Sun Feb 10 2002 - 13:41:04 CST