我试图通过创建一个过程来创建一个 XML 输出文件,并将该过程用于并发请求。请找到下面的包过程代码。
并发程序出错
“原因:FDPSTP 由于 ORA-19202 失败:XML 处理中发生错误 ORA-22806:不是对象或 REF”。
CREATE OR REPLACE PACKAGE BODY xx_outbound_xml1
AS
PROCEDURE xx_insert_outbound_xml1 (
errbuff OUT VARCHAR2,
errcode OUT NUMBER
)
IS
ln_ctx DBMS_XMLGEN.ctxhandle;
lc_xml_clob CLOB;
BEGIN
ln_ctx :=
DBMS_XMLGEN.newcontext
( 'SELECT XMLELEMENT("litleRequest",
XMLATTRIBUTES('
|| 'to_char(sysdate,''DDMMYYYHH24MI:SS'')'
|| ' AS "Id" ),
(SELECT
XMLAGG(
XMLELEMENT(
evalname(Decode((select order_type FROM my_orders WHERE order_id = mo.order_id),''CO'',''"Credit"'',''"Sale"'')).getstringval(),
XMLFOREST (
mo.order_id AS "orderId",
mo.order_type as "orderType"
)
)
)
FROM my_orders mo
)
) xml
FROM dual'
);
DBMS_XMLGEN.setrowsettag (ln_ctx, NULL);
DBMS_XMLGEN.setrowtag (ln_ctx, NULL);
--DBMS_XMLGEN.setNullHandling(ln_ctx,dbms_xmlgen.EMPTY_TAG);
lc_xml_clob := DBMS_XMLGEN.getxml (ln_ctx);
lc_xml_clob := REPLACE (lc_xml_clob, '<XML>', '');
lc_xml_clob := REPLACE (lc_xml_clob, '</XML>', '');
DBMS_XSLPROCESSOR.clob2file (lc_xml_clob,
'INBOUNDFOLDER',
'output.xml',
0
);
DBMS_LOB.freetemporary (lc_xml_clob);
END xx_insert_outbound_xml1;
END xx_outbound_xml1;
如果订单类型是 CO,那么标签应该是 Credit,或者如果 order_type 是 SO,那么标签应该是 Sales。
我的输出应该是这样的: