December 2010
Intermediate to advanced
451 pages
11h 16m
English
You have a VARRAY with a defined maximum size, but not all elements are initialized, and you need to add more elements to the collection.
Use the EXTEND method to create new elements within the predefined boundaries. The following example adds five elements using a loop:
DECLARE
TYPE vtype IS VARRAY(5) OF DATE;
vdates vtype := vtype (sysdate, sysdate+1, sysdate+2); -- initialize 3 of the 5 elements
BEGIN
DBMS_OUTPUT.PUT_LINE ('vdates size is: ' || vdates.COUNT);
FOR i IN 1..5 LOOP
if NOT vdates.EXISTS(i) then
vdates.EXTEND;
vdates(i) := SYSDATE + i;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE ('vdates size is: ' || vdates.COUNT);
END; ...Read now
Unlock full access