number_list.EXTEND(2): Add two null value members at the end of the list. : Table of Number « Collections « Oracle PL/SQL Tutorial






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> DECLARE
  2     number_list NUMBER_TABLE;
  3
  4   BEGIN
  5     IF NOT number_list.EXISTS(1) THEN
  6       number_list := number_table(1,2,3,4,5);
  7     END IF;
  8
  9     print_list(number_list);
 10
 11     -- Add two null value members at the end of the list.
 12     number_list.EXTEND(2);
 13
 14     -- Print revised contents.
 15     DBMS_OUTPUT.PUT_LINE(CHR(10)||'Nested table after a deletion');
 16     print_list(number_list);
 17   END;
 18   /
List 1
List 2
List 3
List 4
List 5

Nested table after a deletion
List 1
List 2
List 3
List 4
List 5
List
List

PL/SQL procedure successfully completed.

SQL>
SQL>








26.23.Table of Number
26.23.1.An example of declaring an Index-by table
26.23.2.Initializing a Nested Table
26.23.3.NULL and Empty Nested Tables and NULL elements
26.23.4.Is a table collection a null value
26.23.5.ORA-06531: Reference to uninitialized collection
26.23.6.Initialize table collection with null value
26.23.7.Accessing an Index-by table
26.23.8.Accessing an entire Index-by table
26.23.9.Accessing an undefined row of an Index-by table
26.23.10.Assigning rows of an Index-By table by means of a LOOP
26.23.11.Deleting an Index-by table using an empty Index-by table
26.23.12.Using the EXISTS method
26.23.13.An example of COUNT method
26.23.14.An example of the DELETE method
26.23.15.An example of the FIRST, LAST and NEXT methods
26.23.16.number_list.EXTEND(2): Add two null value members at the end of the list.
26.23.17.number_list.EXTEND(3,4): Add three members at the end of the list and copy the contents of item 4
26.23.18.Associative arrays
26.23.19.Accessing Nested Table elements
26.23.20.ORA-06533: Subscript beyond count
26.23.21.compare two tables of integers
26.23.22.Loop through table of number by index