Use LOOP to output all elements in a table collection : Table of Type « Collections « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE TABLE birthday (
  2     party_date DATE,
  3     fav_present VARCHAR2(100)
  4  );

Table created.

SQL>
SQL> INSERT INTO birthday VALUES ('01-OCT-92', 'A');

1 row created.

SQL> INSERT INTO birthday VALUES ('01-OCT-98', 'B');

1 row created.

SQL>
SQL> DECLARE
  2     TYPE name_tt IS TABLE OF birthday.fav_present%TYPE INDEX BY BINARY_INTEGER;
  3     the_best name_tt;
  4     indx PLS_INTEGER;
  5  BEGIN
  6     indx := the_best.FIRST;
  7     LOOP
  8        EXIT WHEN indx IS NULL;
  9        DBMS_OUTPUT.PUT_LINE (the_best(indx));
 10        indx := the_best.NEXT (indx);
 11     END LOOP;
 12  END;
 13  /

PL/SQL procedure successfully completed.

SQL>
SQL> drop table birthday;

Table dropped.

SQL>
SQL>








26.26.Table of Type
26.26.1.Table of type
26.26.2.Use of PL/SQL tables of types
26.26.3.Use LOOP to output all elements in a table collection
26.26.4.Forall in value of table of type
26.26.5.Table of user-defined types
26.26.6.Select user-defined type into table collection of user-defined types