如何确定DBMS_AQ.DEQUEUE_ARRAY的有效内容类型

时间:2012-02-08 21:03:28

标签: oracle oracle10g queueing

我试图在Oracle 10.2.0.4.0中使用DBMS_AQ.DEQUEUE_ARRAY函数。浏览队列的内容。有没有办法确定用于消息数组的类型?我可以使用一些“通用”类型吗?我正在尝试的内容如下:

CREATE or REPLACE TYPE I_NEED_THIS_TYPE AS ????
/

CREATE or REPLACE myFunction
  return pls_integer
IS

dequeue_options     DBMS_AQ.dequeue_options_t;
message_properties  DBMS_AQ.message_properties_t;
msgPropArray   DBMS_AQ.message_properties_array_t;
msgIdArray      DBMS_AQ.msgid_array_t;
msgArray        I_NEED_THIS_TYPE;
cMsgs pls_integer;

BEGIN

msgPropArray  := DBMS_AQ.message_properties_array_t();
msgIdArray     := dbms_aq.msgid_array_t();
msgArray       := I_NEED_THIS_TYPE();


--where SOME_NAME and SOME_QUEUE_TABLE I get from
--select owner,name from user_queues;
dequeue_options.CONSUMER_NAME := 'SOME_NAME.SOME_QUEUE_TABLE';
dequeue_options.DEQUEUE_MODE := DBMS_AQ.BROWSE;
dequeue_options.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
dequeue_options.VISIBILITY := DBMS_AQ.IMMEDIATE;
dequeue_options.WAIT := DBMS_AQ.NO_WAIT;
dequeue_options.MSGID := null;

   cMsgs := DBMS_AQ.DEQUEUE_ARRAY(
      queue_name          =>     'MY_QUEUE_NAME',
      dequeue_options     =>     dequeue_options,
      array_size          =>     30,
      message_properties  =>     msgPropArray,
      payload_array       =>     msgArray,
      msgid_array         =>     msgIdArray);

  return cMsgs;
END;
/

我尝试了很多

的组合
CREATE or REPLACE TYPE I_NEED_THIS_TYPE AS VARRAY(100) of CLOB;
CREATE or REPLACE TYPE I_NEED_THIS_TYPE AS VARRAY(100) of SYS.xmltype;
CREATE or REPLACE TYPE I_NEED_THIS_TYPE AS VARRAY(100) of xmltype;


CREATE or REPLACE TYPE I_NEED_THIS_TYPE AS OBJECT(
id NUMBER,
xmlData CLOB
)


DECLARE
TYPE assoc_array is TABLE OF CLOB index by pls_integer;
myData assoc_array;

我能够按预期使用DBMS_AQ.DEQUEUE函数,其消息参数是SYS.xmltype。

我无法使用管理员帐户,但确实具有创建类型和功能的权限。如果无法确定此信息,我应该要求管理员运行哪种类型的查询,以便我可以确定此信息?

谢谢!

1 个答案:

答案 0 :(得分:0)

运行CREATE_QUEUE_TABLE时,您的队列很可能是使用有效负载类型创建的。因此,您可以通过执行此查询找出队列的类型:

select OBJECT_TYPE
  from DBA_QUEUE_TABLES
 where OWNER = 'SOME_NAME' and QUEUE_TABLE = 'SOME_QUEUE_TABLE';

然后你的功能可以使用它:

type I_NEED_THIS_TYPE is varray(100) of <OBJECT_TYPE>;