DECLARE
TYPE numlist IS TABLE OF INTEGER;
n NUMLIST := Numlist(2,4,6,8);
x NUMLIST := Numlist(1,3);
PROCEDURE print_numlist
(the_list NUMLIST)
IS
output VARCHAR2(128);
BEGIN
FOR i IN the_list.FIRST.. the_list.LAST LOOP
output := output
||Nvl(To_char(The_list(i)),'NULL')
||' ';
END LOOP;
dbms_output.Put_line(output);
END;
BEGIN
dbms_output.Put_line('At first, N has '
||n.COUNT
||' elements.');
n.EXTEND(5); -- Add 5 elements at the end.
dbms_output.Put_line('Now N has '
||n.COUNT
||' elements.');
-- Elements 5, 6, 7, 8, and 9 are all NULL.
Print_numlist(n);
dbms_output.Put_line('At first, X has '
||x.COUNT
||' elements.');
x.EXTEND(4,2); -- Add 4 elements at the end.
dbms_output.Put_line('Now X has '
||x.COUNT
||' elements.');
-- Elements 3, 4, 5, and 6 are copies of element #2.
Print_numlist(x);
END;
/
Using EXTEND to Increase the Size of a Collection
0 comments:
Post a Comment