通过查阅网上文章,发现很多Advanced Queue的例子无法跑起来。

参考了英文网站,可以正常运行成功。

http://www.orafaq.com/wiki/Advanced_Queueing

第一步:

建立object,建立queue table,建立queue,然后启动queue。
*****************************************************************************

[oracle@localhost ~]$ cat q01.sql

CREATE OR REPLACE TYPE event_msg_type AS OBJECT (
  name            VARCHAR2(10),
  current_status  NUMBER(5),
  next_status     NUMBER(5)
);

EXECUTE DBMS_AQADM.create_queue_table( -
   queue_table        =>  'testq.event_queue_tab', -
   queue_payload_type =>  'testq.event_msg_type');

EXECUTE DBMS_AQADM.create_queue( -
   queue_name         =>  'testq.event_queue', -
   queue_table        =>  'testq.event_queue_tab');

EXECUTE DBMS_AQADM.start_queue( -
   queue_name         => 'testq.event_queue', -
   enqueue            => TRUE);
/
[oracle@localhost ~]$

执行:

SQL> @q01.sql;

Type created.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

*****************************************************************************

第二步:

执行enqueue操作。

*****************************************************************************

[oracle@localhost ~]$ cat q02.sql
DECLARE
  l_enqueue_options    DBMS_AQ.enqueue_options_t;
  l_message_properties DBMS_AQ.message_properties_t;
  l_message_handle     RAW(16);
  l_event_msg          TESTQ.event_msg_type;
BEGIN
  l_event_msg := TESTQ.event_msg_type('REPORTER', 1, 2);
  DBMS_AQ.enqueue(queue_name         => 'testq.event_queue',
                  enqueue_options    => l_enqueue_options,
                  message_properties => l_message_properties,
                  payload            => l_event_msg,
                  msgid              => l_message_handle);
  COMMIT;
END;
/
[oracle@localhost ~]$

SQL> set serveroutput on;
SQL>
SQL> @q02.sql;

PL/SQL procedure successfully completed.

SQL>

*****************************************************************************

第三步:

执行dequeue操作。

*****************************************************************************

[oracle@localhost ~]$ cat q03.sql
DECLARE
  l_dequeue_options    DBMS_AQ.dequeue_options_t;
  l_message_properties DBMS_AQ.message_properties_t;
  l_message_handle     RAW(16);
  l_event_msg          TESTQ.event_msg_type;
BEGIN
  DBMS_AQ.dequeue(queue_name         => 'testq.event_queue',
                  dequeue_options    => l_dequeue_options,
                  message_properties => l_message_properties,
                  payload            => l_event_msg,
                  msgid              => l_message_handle);
  DBMS_OUTPUT.put_line('Event Name    : ' || l_event_msg.name);
  DBMS_OUTPUT.put_line('Current Status: ' || l_event_msg.current_status);
  DBMS_OUTPUT.put_line('Next Status   : ' || l_event_msg.next_status);
  COMMIT;
END;
/
[oracle@localhost ~]$

执行

SQL> @q03.sql;
Event Name    : REPORTER
Current Status: 1
Next Status   : 2

PL/SQL procedure successfully completed.

SQL>

*****************************************************************************

备忘!

可以运行的Oracle Advanced Queue的例子的更多相关文章

  1. Oracle Advanced Pricing White Papers

    Oracle Order Management - Version 11.5.10.0 and later Oracle Advanced Pricing - Version 11.5.10 and ...

  2. oracle regexp_like介绍和例子

    oracle regexp_like介绍和例子 学习了:http://www.cnblogs.com/einyboy/archive/2012/08/01/2617606.html ORACLE中的支 ...

  3. 在 Cloudera Data Flow 上运行你的第一个 Flink 例子

    文档编写目的 Cloudera Data Flow(CDF) 作为 Cloudera 一个独立的产品单元,围绕着实时数据采集,实时数据处理和实时数据分析有多个不同的功能模块,如下图所示: 图中 4 个 ...

  4. oracle中的存储过程例子

    用了两年Oracle还没写过存储过程,真是十分惭愧,从今天开始学习Oracle存储过程,完全零起点,争取每日一篇学习笔记,可能开始认识的不全面甚至有错误,但坚持下来一定会有收获. . 建立一个存储过程 ...

  5. 让powershell同时只能运行一个脚本(进程互斥例子)

    powershell,mutex,互斥,进程互斥,脚本互斥 powershell脚本互斥例子,在powershell类别文章中,声明原创唯一. powershell 传教士 原创文章 2016-07- ...

  6. oracle安全应用角色例子

    今天在做看OCP的时候有道题是关于应用安全角色的,不是很明白,在网上找了个例子按照步骤验证了下.QUESTION 48You want to create a role to meet these r ...

  7. 一个完整的Oracle建表的例子

    建表一般来说是个挺简单的事情,但是Oracle的建表语句有很多可选的参数,有些我们可能平时不太用,用的时候又不知道怎么用,这里就写一个较完整的建表的例子: [sql] CREATE TABLE ban ...

  8. 运行hadoop自带的wordcount例子程序

    1.准备文件 [root@master ~]# cat input.txt hello java hello python hello c hello java hello js hello html ...

  9. 使用oracle的存储过程的例子

    十几年没有用oracle的存储过程了,有些东西已经忘了,没有想到今天又要用.在这里写个例子.它演示了存储过程的格式,游标的使用,循环.判断的使用,还有直接执行一个拼接的SQL的用法.以下是代码: cr ...

随机推荐

  1. 在asp.net一般应用程序中使用session

    通常我们经常,通过session判定用户是否登录.还有一些临时的.重要的数据也尝尝存放在Session中. 在页面我们很容易的得到Session的值,但在类中就会遇到一些问题.也知道通过下面的方法得到 ...

  2. 转:只能选择GridView中的一个CheckBox(单选CheckBox)

    方法1: protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e){CheckBox cbx = e.R ...

  3. 使用GPUImage渲染图片教程

    使用GPUImage渲染图片教程 Prepare - 准备 GPUImage开源库并不像普通的开源库那样子,拖进你的工程中就可以用.以下将详细的告诉你如何将GPUImage导入到你的工程当中. 首先上 ...

  4. MDT配置数据库

    连接数据库可以使用数据库账户和Windows集成身份验证两种方法:使用数据库账户:1.连接数据库时选择TCP/IP2.在数据库中添加相应规则后,配置数据库3.在CustomSettings.ini文件 ...

  5. Linux内核态和用户态

    两张图说明Linux内核态和用户态之间的关系

  6. RESTful 架构基础

    源自:https://mp.weixin.qq.com/s/wEr2jAVphzB1G_MISlLU0w REST(Representational State Transfer)架构风格是一种世界观 ...

  7. Linux 系统其他重要文件

    其他重要目录 /usr /usr/local 通过源码安装,没有特别指定,就在这个文件下用户自编译软件存放地方 /usr/src 源代码程序 + 内核源代码程序存放目录 /var /var/log/m ...

  8. (转)如何安装 easy installer+pip

    http://blog.csdn.net/wuxiaobingandbob/article/details/42457807

  9. October 09th 2017 Week 41st Monday

    My motto is: Contended with little, yet wishing for more. 我的座右铭是:为一点点感到满足,但希望获得更多. If you can live y ...

  10. 有料面试题之--Object里面的方法

    阿里的面试题里面有个题很奇妙:你知道Object类里面有哪些方法吗? 绝大部分猿类都知道 有hashcode .equals .clone.toString 只有部分人会回答有 wait和notify ...