Table collection type parameter : Parameters « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
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.vancouver_employees MULTISET UNION
  5        employees_pkg.newyork_employees;
  6
  7     employees_pkg.show_employees ( 'STEVEN then VEVA', our_favorites);
  8  END;
  9  /

PL/SQL procedure successfully completed.








27.14.Parameters
27.14.1.Defining Formal Parameters
27.14.2.There are three types of formal parameters in subprograms: IN, OUT, and IN OUT.
27.14.3.Define function with NUMBER type parameter
27.14.4.Function without parameter
27.14.5.Use IF/ELSIF/ELSE to verify the input parameter
27.14.6.Use ROWTYPE as the parameter
27.14.7.Passing parameters to procedures
27.14.8.Using Named Notation
27.14.9.Use mixed notation to avoid the second parameter, but keep the first and third
27.14.10.Parameter Modes
27.14.11.Positional Notation
27.14.12.Positional vs. named parameter passing.
27.14.13.Parameter Default Values
27.14.14.Specifying procedure or function parameters Positional notation
27.14.15.Table collection type parameter
27.14.16.Mixed Name and Position Notation Calls