遇到符号“DECLARE”并遇到符号“end-of-file”

时间:2015-09-11 15:14:20

标签: sql oracle11g oracle-sqldeveloper

我正在关注Oracle的教程,在最后一步中,我正在尝试执行一个SQL脚本,我从DECLARE和文件结尾处获取错误。知道我哪里错了吗?以下是脚本:

create or replace
PROCEDURE ENQUEUE_TEXT(
 payload IN VARCHAR2 )
AS
 enqueue_options DBMS_AQ.enqueue_options_t;
 message_properties DBMS_AQ.message_properties_t;
 message_handle RAW (16);
 user_prop_array SYS.aq$_jms_userproparray;
 AGENT SYS.aq$_agent;
 header SYS.aq$_jms_header;
 MESSAGE SYS.aq$_jms_message;
BEGIN
 AGENT := SYS.aq$_agent ('', NULL, 0);
 AGENT.protocol := 0;
 user_prop_array := SYS.aq$_jms_userproparray ();
 header := SYS.aq$_jms_header (AGENT, '', 'aq1', '', '', '', user_prop_array);
 MESSAGE := SYS.aq$_jms_message.construct (0);
 MESSAGE.set_text (payload);
 MESSAGE.set_userid ('Userid_if_reqd');
 MESSAGE.set_string_property ('JMS_OracleDeliveryMode', 2);
 --(header, length(message_text), message_text, null);
 DBMS_AQ.enqueue (queue_name => 'userQueue', enqueue_options => enqueue_options,
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
 COMMIT;
END ENQUEUE_TEXT;
DECLARE
  PAYLOAD varchar2(200);
BEGIN
  PAYLOAD := 'Hello from AQ !';
  ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;

1 个答案:

答案 0 :(得分:1)

你必须在创建proc之后放置一个/

....
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
 COMMIT;
END ENQUEUE_TEXT;
/  

--COMMIT; 
--/

DECLARE
  PAYLOAD varchar2(200);
BEGIN
  PAYLOAD := 'Hello from AQ !';
  ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;

可能缺少COMMIT;