MULTISET EXCEPT : MULTISET UNION « Set « Oracle PL/SQL Tutorial






SQL> DECLARE
  2      TYPE nested_type IS TABLE OF NUMBER;
  3      nt1 nested_type := nested_type(1,2,3);
  4      nt2 nested_type := nested_type(3,2,1);
  5      nt3 nested_type := nested_type(2,3,1,3);
  6      nt4 nested_type := nested_type(1,2,4);
  7      answer nested_type;
  8      PROCEDURE show_answer (str IN VARCHAR2)
  9      IS
 10         l_row   PLS_INTEGER;
 11      BEGIN
 12         DBMS_OUTPUT.put_line (str);
 13         l_row := answer.FIRST;
 14
 15         WHILE (l_row IS NOT NULL)
 16         LOOP
 17            DBMS_OUTPUT.put_line (l_row || '=' || answer (l_row));
 18            l_row := answer.NEXT (l_row);
 19         END LOOP;
 20
 21         DBMS_OUTPUT.put_line ('');
 22      END show_answer;
 23  BEGIN
 24      answer := nt1 MULTISET UNION nt4;
 25      show_answer('nt1 MULTISET UNION nt4');
 26      answer := nt1 MULTISET UNION nt3;
 27      show_answer('nt1 MULTISET UNION nt3');
 28      answer := nt1 MULTISET UNION DISTINCT nt3;
 29      show_answer('nt1 MULTISET UNION DISTINCT nt3');
 30      answer := nt2 MULTISET INTERSECT nt3;
 31      show_answer('nt2 MULTISET INTERSECT nt3');
 32      answer := nt2 MULTISET INTERSECT DISTINCT nt3;
 33      show_answer('nt2 MULTISET INTERSECT DISTINCT nt3');
 34      answer := SET(nt3);
 35      show_answer('SET(nt3)');
 36      answer := nt3 MULTISET EXCEPT nt2;
 37      show_answer('nt3 MULTISET EXCEPT nt2');
 38      answer := nt3 MULTISET EXCEPT DISTINCT nt2;
 39      show_answer('nt3 MULTISET EXCEPT DISTINCT nt2');
 40  END;
 41  /

PL/SQL procedure successfully completed.








3.6.MULTISET UNION
3.6.1.MULTISET UNION
3.6.2.MULTISET UNION DISTINCT
3.6.3.MULTISET EXCEPT