Constructor of table collection : Table of Varchar2 « Collections « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE TYPE strings_nt IS TABLE OF VARCHAR2(100);
  2  /

Type created.

SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE employees_pkg
  2  IS
  3     vancouver_employees strings_nt := strings_nt ('R', 'H', 'D', 'S', 'C');
  4     newyork_employees   strings_nt := strings_nt ('H', 'S', 'A');
  5     boston_employees    strings_nt := strings_nt ('S', 'D');
  6
  7     PROCEDURE show_employees(title_in IN VARCHAR2,employees_in IN strings_nt);
  8  END;
  9  /

Package created.

SQL> SHO ERR
No errors.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY employees_pkg
  2  IS
  3     PROCEDURE show_employees(title_in IN VARCHAR2,employees_in IN strings_nt)
  4     IS
  5     BEGIN
  6        DBMS_OUTPUT.put_line (title_in);
  7
  8        FOR indx IN employees_in.FIRST .. employees_in.LAST
  9        LOOP
 10           DBMS_OUTPUT.put_line (indx || ' = ' || employees_in (indx));
 11        END LOOP;
 12
 13     END show_employees;
 14  END;
 15  /

Package body created.

SQL>
SQL>
SQL> SHOw error
No errors.
SQL>
SQL>
SQL> DECLARE
  2     our_favorites strings_nt := strings_nt ();
  3  BEGIN
  4     our_favorites :=  employees_pkg.newyork_employees
  5         MULTISET UNION
  6      employees_pkg.vancouver_employees;
  7
  8     employees_pkg.show_employees('VEVA THEN STEVEN', our_favorites);
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL>








26.27.Table of Varchar2
26.27.1.Demonstrate Associative Arrays
26.27.2.compare table of varchar2
26.27.3.Constructor of table collection
26.27.4.for index between first and last
26.27.5.Initialize table collection of varchar2
26.27.6.Table collection variable assignment
26.27.7.Loading and accessing an array of varchar2
26.27.8.A procedure that uses an implicit cursor loop to load an array with employee number and name.