0

可能重复:
Oracle 中的 PL/SQL 函数看不到 DBMS_AQ

以下是我将数据排入队列的过程,在运行该过程时出现编译错误,我找不到出错的地方。请帮我解决。

CREATE OR REPLACE PROCEDURE p_enqueue(msg IN VARCHAR2)
AS
PRAGMA AUTONOMOUS_TRANSACTION;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
BEGIN
dbms_aq.enqueue( queue_name => 'example_queue',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message_type(msg),
msgid => message_handle);
COMMIT;
END;

错误:

PLS-00201:必须声明标识符“DBMS_AQ”

PLS-00320:此表达式类型的声明不完整或格式错误

当我尝试使用授予权限时,出现以下错误

错误 ORA-01031: 权限不足

如果这是我运行下面的 pl/sql 块来排队消息的问题,那么程序已成功创建。如果权限不存在怎么可能?

DECLARE
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message message_typ;

BEGIN
message := message_typ('NORMAL MESSAGE',
'enqueued to msg_queue first.');

dbms_aq.enqueue(queue_name => 'msg_queue', 
enqueue_options => enqueue_options, 
message_properties => message_properties, 
payload => message, 
msgid => message_handle);

COMMIT;
end; 
4

2 回答 2

0

错误消息说 DBMS_AQ 不知道。由于这是 SYS 拥有的 Oracle 包,因此它确实存在。所以你失去了查看和执行它的权利。

你跑了吗

grant EXECUTE ON DBMS_AQ to appuser;

正如我对您之前的一个问题的回答中明确显示的那样?

于 2012-12-26T11:25:23.380 回答
0

检查 DBMS_AQ pkg 并找出您使用的程序的强制参数。

下面的查询对队列很有用。

SELECT name, enqueue_enabled, dequeue_enabled
FROM user_queues;

SELECT owner, queue_name, queue_table, consumer_name
FROM dba_queue_subscribers;

SELECT queue_name, consumer_name, address, protocol, delivery_mode, queue_to_queue
FROM user_queue_subscribers;

SELECT qname, destination, start_date, start_time, propagation_window, next_time, latency
FROM user_queue_schedules;

SELECT qname, process_name, session_id, instance, last_run_date, last_run_time, current_start_date
FROM user_queue_schedules;

SELECT qname, current_start_time, next_run_date, next_run_time, total_time, total_number
FROM user_queue_schedules;

SELECT qname, total_bytes, max_number, max_bytes, avg_number, avg_size, avg_time
FROM user_queue_schedules;
于 2012-12-26T12:16:00.533 回答