在xmltype变量中选择oracle xmltype表字段会产生一个null对象

时间:2012-06-13 23:42:04

标签: oracle plsql xmltype

这一直困扰着我。我使用oracle流将消息写入oracle AQ队列作为存储过程的一部分。下面是存储过程,其中显示了以下相关部分:

CREATE OR REPLACE PROCEDURE ESBEVENT.esb_dml_handler(in_any IN ANYDATA) IS

l_enqueue_options dbms_aq.enqueue_options_t;
l_message_properties dbms_aq.message_properties_t;
l_message sys.aq$_jms_text_message;
l_msgid raw(16);
l_xmlmsg SYS.XMLTYPE;
err_num NUMBER;
err_msg VARCHAR2(100);

BEGIN
    BEGIN
    l_message := sys.aq$_jms_text_message.construct;
    l_xmlmsg := DBMS_STREAMS.CONVERT_LCR_TO_XML(in_any);
    l_message.set_text(l_xmlmsg.getClobVal());

    dbms_aq.enqueue
    ( queue_name => 'esbevent.esb_jms_queue'
    , enqueue_options => l_enqueue_options
    , message_properties => l_message_properties
    , payload => l_message
    , msgid => l_msgid
    );
    COMMIT;

    err_num := '';
    err_msg := 'Message Queued Successfully';

    EXCEPTION
    WHEN OTHERS THEN
        err_num := SQLCODE;
        err_msg := SUBSTR(SQLERRM, 1, 1000);
        INSERT INTO esbevent.esb_dml_handler_error_t VALUES (SYSDATE, err_num||' - '||err_msg );
END;

INSERT INTO esbevent.esb_jms_msg_memento_t VALUES (esb_jms_msg_memento_seq.nextval,     SYSDATE, l_xmlmsg, err_num||' - '||err_msg );
COMMIT;


END;

在enqueue之后,我将在表esb_jms_msg_memento_t中作为XMLTYPE发送的消息存储起来。如果我们在后续处理中遇到问题,这将启用重新发送。我现在正在尝试编写一个块来提取XMLTYPE字段数据并将其再次写入AQ。目前情况如下:

DECLARE
   l_enqueue_options      DBMS_AQ.ENQUEUE_OPTIONS_T;
   l_message_properties   DBMS_AQ.MESSAGE_PROPERTIES_T;
   l_message              SYS.aq$_jms_text_message;
   l_msgid                RAW (16);
   l_xmlmsg               XMLTYPE;

BEGIN
   SELECT msg_payload
     INTO l_xmlmsg
     FROM esb_jms_msg_memento_t
    WHERE UNIQUE_ID = '815929';

   l_message.set_text (l_xmlmsg.getClobVal ()); --null self error here


   DBMS_AQ.enqueue (queue_name           => 'esbevent.esb_jms_queue',
                    enqueue_options      => l_enqueue_options,
                    message_properties   => l_message_properties,
                    payload              => l_message,
                    msgid                => l_msgid);
   COMMIT;
END;

当我运行时,我收到错误:

ORA-30625:禁止对NULL SELF参数进行方法调度 ORA-06512:第22行

看来我可以将XMLTYPE变量和XMLTYPE变量插入到XMLTYPE字段中而不是相反吗?

1 个答案:

答案 0 :(得分:0)

我发布后立即解决...

忘了构建l_message:

l_message := sys.aq$_jms_text_message.construct;

卫生署!