Oracle PL/SQL Tutorial/Set/SUBMULTISET — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:45, 26 мая 2010

SUBMULTISET OF and NOT SUBMULTISET OF

SQL>
SQL> CREATE OR REPLACE TYPE strings_nt IS TABLE OF VARCHAR2(100);
  2  /
Type created.
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 (
  8        title_in   IN   VARCHAR2
  9      , employees_in    IN   strings_nt
 10     );
 11  END;
 12  /
Package created.
SQL> SHO ERR
No errors.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY employees_pkg
  2  IS
  3     PROCEDURE show_employees (
  4        title_in   IN   VARCHAR2
  5      , employees_in    IN   strings_nt
  6     )
  7     IS
  8     BEGIN
  9        DBMS_OUTPUT.put_line (title_in);
 10
 11        FOR indx IN employees_in.FIRST .. employees_in.LAST
 12        LOOP
 13           DBMS_OUTPUT.put_line (indx || " = " || employees_in (indx));
 14        END LOOP;
 15
 16        DBMS_OUTPUT.put_line ("_");
 17     END show_employees;
 18  END;
 19  /
Package body created.
SQL> SHOw error
No errors.
SQL>
SQL> DECLARE
  2     PROCEDURE bpl (val IN BOOLEAN, str IN VARCHAR2)
  3     IS
  4     BEGIN
  5        IF val
  6        THEN
  7           DBMS_OUTPUT.put_line (str || "-TRUE");
  8        ELSIF NOT val
  9        THEN
 10           DBMS_OUTPUT.put_line (str || "-FALSE");
 11        ELSE
 12           DBMS_OUTPUT.put_line (str || "-NULL");
 13        END IF;
 14     END;
 15  BEGIN
 16     bpl (employees_pkg.vancouver_employees SUBMULTISET OF employees_pkg.boston_employees
 17        , "Result: ");
 18     bpl (employees_pkg.boston_employees SUBMULTISET OF employees_pkg.vancouver_employees
 19        , "Result: ");
 20
 21     bpl (employees_pkg.vancouver_employees NOT SUBMULTISET OF employees_pkg.boston_employees
 22        , "Result: ");
 23     bpl (employees_pkg.boston_employees NOT SUBMULTISET OF employees_pkg.vancouver_employees
 24        , "Result: ");
 25  END;
 26  /
PL/SQL procedure successfully completed.
SQL>
SQL>