Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Advanced Queue & bind variables

714279Jul 28 2009 — edited Jul 31 2009
Help needed

I have created Advanced Queue. Payload is below

-- create payload type
CREATE TYPE ot_account_lock AS OBJECT
(
ID NUMBER
-- constructor
,CONSTRUCTOR FUNCTION ot_account_lock RETURN SELF AS RESULT
);
/

CREATE TYPE BODY ot_account_lock AS
-- constructor
CONSTRUCTOR FUNCTION ot_account_lock RETURN SELF AS RESULT IS
BEGIN
RETURN;
END ot_account_lock;

END;
/


Running this stuff. Start checking Gets, Puts, Checks (does element is exist in the queue without dequeuing it). All works fine.

Problem is the next. I'm getting not the FIRST element from the queue but with specific ID


l_dequeue_options.visibility := dbms_aq.IMMEDIATE; -- dequeuing in autonomous transaction
l_dequeue_options.WAIT := dbms_aq.no_wait; -- if element does not exist - we don't wait

-- !!!!!!!!!!!!!!!!!

l_dequeue_options.deq_condition := 'tab.user_data.id = ' || l_tla_id; -- get element by ID

-- !!!!!!!!!!!!!!!!!

dbms_aq.dequeue(c_queue_name, l_dequeue_options, l_message_options, l_payload, l_msg_id);



In a trace file I see that given dequeue option Oracle consider as a string not as a bind variable.


select tab.row_id, tab.msgid, tab.corrid, tab.priority, tab.delay,
tab.expiration, tab.retry_count, tab.exception_qschema,
tab.exception_queue, tab.chain_no, tab.local_order_no, tab.enq_time,
tab.time_manager_info, tab.state, tab.enq_tid, tab.step_no,
tab.sender_name, tab.sender_address, tab.sender_protocol,
tab.dequeue_msgid, tab.user_prop, tab.user_data
from
"ATISHAYEV"."AQ$_ACCOUNTS_LOCK_F" tab where q_name = :1 and (state = :2 )
and (tab.user_data.id = 370)


call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 27 0.00 0.00 0 3 0 0
Execute 28 0.03 0.03 0 4 0 0
Fetch 28 0.05 0.05 0 1241 0 21
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 83 0.09 0.09 0 1248 0 21


Here is this point

from
"ATISHAYEV"."AQ$_ACCOUNTS_LOCK_F" tab where q_name = :1 and (state = :2 )
and (tab.user_data.id = 370)

Instead of :3 he just addes 370. And so on for each id...

As result this query was parsed 27 times and executed 28 times...

When I running 30 000 operations the result, as you understand, is far away from fair...for each execution there is a one parse.



Does anybody know how to tell Oracle in the case of using "deq_condition" option of the "dbms_aq.dequeue" method to use bind variable instead of just adding string?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2009
Added on Jul 28 2009
6 comments
1,741 views