Repository navigation
Expand file tree
/
Copy path10g_tab_compare_with_coll.sql
More file actions
79 lines (67 loc) · 1.63 KB
/
Copy path10g_tab_compare_with_coll.sql
File metadata and controls
79 lines (67 loc) · 1.63 KB
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
71
72
73
74
75
76
77
78
79
CREATE TABLE employee2
AS
SELECT * FROM employee;
DECLARE
-- Use for testing of equality between relational tables?
TYPE employee_tt IS TABLE OF employee%ROWTYPE;
group1 employee_tt;
group2 employee_tt;
l_count INTEGER;
t1 INTEGER;
PROCEDURE load1 (e IN OUT employee_tt)
IS
BEGIN
SELECT *
BULK COLLECT INTO e
FROM employee;
END;
PROCEDURE load2 (e IN OUT employee_tt)
IS
BEGIN
SELECT *
BULK COLLECT INTO e
FROM employee2;
END;
BEGIN
-- We can use = or !=, but not < or >.
t1 := DBMS_UTILITY.get_time;
load1 (group1);
load2 (group2);
FOR n IN 1 .. 1000
LOOP
IF group1 = group2
THEN
NULL;
END IF;
END LOOP;
DBMS_OUTPUT.put_line (DBMS_UTILITY.get_time - t1);
t1 := DBMS_UTILITY.get_time;
FOR n IN 1 .. 1000
LOOP
SELECT COUNT (*)
INTO l_count
FROM ((SELECT *
FROM employee
MINUS
SELECT *
FROM employee2)
UNION
(SELECT *
FROM employee2
MINUS
SELECT *
FROM employee));
IF l_count = 0
THEN
NULL;
END IF;
END LOOP;
DBMS_OUTPUT.put_line (DBMS_UTILITY.get_time - t1);
END;
/
/*======================================================================
| Supplement to the fifth edition of Oracle PL/SQL Programming by Steven
| Feuerstein with Bill Pribyl, Copyright (c) 1997-2009 O'Reilly Media, Inc.
| To submit corrections or find more code samples visit
| http://oreilly.com/catalog/9780596514464/
*/