-
Notifications
You must be signed in to change notification settings - Fork 24
/
set_operations.sql
70 lines (46 loc) · 1.77 KB
/
set_operations.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
declare
type nested_type is table of number;
one_two_three nested_type := nested_type(1,2,3);
three_two_one nested_type := nested_type(3,2,1);
two_through_four nested_type := nested_type(2,3,4);
non_distinct nested_type := nested_type(2, 2, 3, 3, 3, 4, 4, 4, 4);
empty_ nested_type := nested_type();
procedure p(n nested_type) is
begin
for i in 1 .. n.count loop
dbms_output.put(n(i) || ' ');
end loop;
dbms_output.new_line;
end p;
begin
p(one_two_three multiset union one_two_three );
p(one_two_three multiset union distinct one_two_three );
p(one_two_three multiset intersect two_through_four);
p(one_two_three multiset except two_through_four);
p(two_through_four multiset except one_two_three );
p( set (two_through_four) );
p( non_distinct );
p( set (non_distinct ) );
dbms_output.put_line(cardinality(non_distinct));
if 4 member of two_through_four then
dbms_output.put_line('Yes, 4 is a member of two_through_four');
else
dbms_output.put_line('No, 4 is not a member of two_through_four');
end if;
if two_through_four is a set then
dbms_output.put_line('two_through_four is a set');
else
dbms_output.put_line('two_through_four is not a set');
end if;
if empty_ is a set then
dbms_output.put_line('empty_ is a set');
else
dbms_output.put_line('empty_ is not a set');
end if;
if empty_ is empty then
dbms_output.put_line('empty_ is empty');
else
dbms_output.put_line('empty_ is not empty');
end if;
end;
/