【问题标题】:Encountered the symbol "DECLARE" and Encountered the symbol "end-of-file"遇到符号“DECLARE”和遇到符号“文件结束”
【发布时间】:2015-09-11 15:14:20
【问题描述】:

我正在学习 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;

【问题讨论】:

    标签: sql oracle11g oracle-sqldeveloper


    【解决方案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;

    【讨论】:

    • 我认为您不需要提交...但是是的,“/”绝对是缺少的项目;)
    • 不,你绝对不需要提交。它隐含在 Oracle 中的任何 DDL 语句中。
    猜你喜欢
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2021-09-05
    • 2016-02-12
    相关资源
    最近更新 更多