forked from oleksiivorobiov/oracle_oci_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aqdemo02.sql
84 lines (71 loc) · 2.08 KB
/
aqdemo02.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Rem
Rem $Header: template.sql 06-feb-96.13:23:14 kosinski Exp $
Rem
Rem aqdemo02.sql
Rem
Rem Copyright (c) Oracle Corporation 2000. All Rights Reserved.
Rem
Rem NAME
Rem aqdemo02.sql - <one-line expansion of the name>
Rem
Rem DESCRIPTION
rem This file loads the enqueue package and enqueues 100 messages
rem (10 messages are enqueued every 3 seconds to a maximum of 100
rem messages).
Rem
Rem NOTES
Rem <other useful comments, qualifications, etc.>
Rem
Rem MODIFIED (MM/DD/YY)
Rem rbhyrava 07/10/00 - Created - bug: 1319922
rem mjaeger 07/14/99 - bug 808870: OCCS: convert tabs, no long lines
rem kmeiyyap 01/27/99 - spool to aqdemo02.log
rem kmeiyyap 09/15/98 - Created
rem
rem
rem
connect aquser/aquser
set serveroutput on
set echo on
spool aqdemo02.log
CREATE OR REPLACE PROCEDURE DEMO_ENQUEUE (userinfo message,
priority number) AS
enq_msgid RAW(16);
eopt dbms_aq.enqueue_options_t;
mprop dbms_aq.message_properties_t;
BEGIN
mprop.priority := priority;
dbms_aq.enqueue(
queue_name => 'input_queue',
enqueue_options => eopt,
message_properties => mprop,
payload => userinfo,
msgid => enq_msgid);
commit;
END demo_enqueue;
/
DECLARE
payload message;
city1 varchar2(30) := 'BELMONT';
city2 varchar2(30) := 'REDWOOD SHORES';
city3 varchar2(30) := 'SUNNYVALE';
city4 varchar2(30) := 'BURLINGAME';
BEGIN
for i in 1..100 LOOP
IF mod (i, 3) = 0 THEN
payload := message(i, city1, mod(i, 3) + 1);
ELSIF mod(i, 4) = 0 THEN
payload := message(i, city2, mod(i, 3) + 1);
ELSIF mod(i, 2) = 0 THEN
payload := message(i, city3, mod(i, 3) + 1);
ELSE
payload := message(i, city4, mod(i, 3) + 1);
END IF;
demo_enqueue(payload, (mod(i, 3) + 1));
IF mod (i, 10) = 0 THEN
dbms_lock.sleep(3);
END IF;
END LOOP;
END;
/
spool off