【发布时间】:2019-04-15 14:32:15
【问题描述】:
我正在使用 DBMS_XMLGEN 从给定查询创建 XML。我使用 XSLT 格式化此 XML。
当结果集为空时遇到问题:DBMS_XMLGen.getXML 返回的 XML 为空(没有空的 XML 节点 - 只是一个 0 大小的 clob)。 我需要 XML 保留与 XSLT 中定义的结构相同的结构,但只需返回空的 XML 节点。
这是代码(lv_FinalQuery 和 lv_Clb_Xsl 在此之前计算)
-- creating new context query
lv_Vc2_location := 'DBMS_XMLGEN.newContext';
lv_queryCtx := DBMS_XMLGen.newContext(lv_FinalQuery);
-- Setting the xsl file with the query context
lv_Vc2_location := 'DBMS_XMLGEN.setXSLT';
DBMS_XMLGen.setXSLT(lv_queryCtx,lv_Clb_Xsl);
-- Setting the rowset tag
lv_Vc2_location := 'DBMS_XMLGEN.setRowsetTag';
DBMS_XMLGen.setRowsetTag(lv_queryCtx, 'USER_LIST');
-- Setting the row tag
lv_Vc2_location := 'DBMS_XMLGEN.setRowTag';
DBMS_XMLGen.setRowTag(lv_queryCtx, 'USER');
-- Getting the xml
lv_Vc2_location := 'DBMS_XMLGEN.getXML';
p_XmlResult := DBMS_XMLGen.getXML(lv_queryCtx);
【问题讨论】:
-
也许您可以尝试将 nvl() 添加到您的值中。例如,nvl(L_USER,'')
-
谢谢,Ahamed,因为有很多列,所以工作量很大。