I am attempting to use the function DBMS_AQ.DEQUEUE_ARRAY in Oracle 10.2.0.4.0. to browse the contents of a queue. Is there a way to determine the type to use for the message array? Is there some "generic" type I could be using? What I'm attempting is as follows:
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;
/
I have tried numerous combinations of
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;
I AM able to use the DBMS_AQ.DEQUEUE function as expected, the message parameter for that is SYS.xmltype.
I am unable to use the administrator account, but do have privilieges to create types and functions. If there is no way to determine this information, what type of query should I ask the administrator to run so that I can determine this information?
Thanks!
It's probable your queue was created with a payload type when CREATE_QUEUE_TABLE
was run. You can therefore find out the type for the queue by performing this query:
select OBJECT_TYPE
from DBA_QUEUE_TABLES
where OWNER = 'SOME_NAME' and QUEUE_TABLE = 'SOME_QUEUE_TABLE';
Then your function can use this:
type I_NEED_THIS_TYPE is varray(100) of <OBJECT_TYPE>;