SQL>
SQL> create or replace TYPE number_table IS TABLE OF INTEGER;
2 /
Type created.
SQL> create or replace PROCEDURE print_list(list_in NUMBER_TABLE) IS
2 BEGIN
3 FOR i IN list_in.FIRST..list_in.LAST LOOP
4 IF list_in.EXISTS(i) THEN
5 DBMS_OUTPUT.PUT_LINE('List '||list_in(i));
6 END IF;
7 END LOOP;
8 END print_list;
9 /
Procedure created.
SQL>
SQL>
SQL>
SQL>
SQL> DECLARE
2 number_list NUMBER_TABLE;
3 BEGIN
4 IF NOT number_list.EXISTS(1) THEN
5 number_list := number_table(1,2,3,4,5);
6 END IF;
7
8 DBMS_OUTPUT.PUT_LINE('Nested table before a deletion');
9 print_list(number_list);
10
11 number_list.DELETE(2);
12
13
14 DBMS_OUTPUT.PUT_LINE(CHR(10)||'Nested table after a deletion');
15 print_list(number_list);
16 END;
17 /
Nested table before a deletion
List 1
List 2
List 3
List 4
List 5
Nested table after a deletion
List 1
List 3
List 4
List 5
PL/SQL procedure successfully completed.
SQL>
SQL>
|