使用 DBMS_XMLGEN.getxml 和 Cursor 表达式时可以删除 XML 的额外嵌套吗?
我一直在搜索文档和谷歌,但我似乎找不到我要找的东西;我的oracle版本是10.2.0.5。
让我们使用这个简单的查询:
select dbms_xmlgen.getxml('select cursor(select ''1'' "one", ''2''
"two", ''3'' "three" from dual) "numbers" from dual') from dual;
结果是:
"<?xml version="1.0"?>
<ROWSET>
<ROW>
<numbers>
<numbers_ROW>
<one>1</one>
<two>2</two>
<three>3</three>
</numbers_ROW>
</numbers>
</ROW>
</ROWSET>
"
问题1:当“numbers”足够时(至少对于我的目的而言),为什么要创建“numbers_row”?
问题 2:我可以摆脱 xmlgen 包或其他包的额外嵌套吗?我使用正则表达式来做到这一点,但这似乎有点不合理。
谢谢你, -乔尔
I've been searching the documentation and google but I can't seem to find what I am looking for; my version of oracle is 10.2.0.5.
Let's use this simple query:
select dbms_xmlgen.getxml('select cursor(select ''1'' "one", ''2''
"two", ''3'' "three" from dual) "numbers" from dual') from dual;
the result is:
"<?xml version="1.0"?>
<ROWSET>
<ROW>
<numbers>
<numbers_ROW>
<one>1</one>
<two>2</two>
<three>3</three>
</numbers_ROW>
</numbers>
</ROW>
</ROWSET>
"
Question1: Why was "numbers_row" created when "numbers" is sufficient (at least for my purposes)?
Question2: Can I get rid of that extra nesting with the xmlgen package or some other package? I'm using regular expressions to do so but it seems a bit unreasonable.
Thank you,
-joel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要阅读这篇文章:
http://www.orafaq.com/wiki/DBMS_XMLGEN
它解释了如何更改Oracle默认值由
DBMS_XMLGEN
包生成的名称。问题 1 的答案是:这是 Oracle DBMS_XMLGEN 包的默认值和行为
对于问题 2:您需要调用一些额外的 DBMS_XMLGEN 过程来更改默认值,因此您需要使用PL/SQL:
会输出:
也有一些过程可以将
值替换为更有意义的值。希望它有帮助...
You need to read through this article:
http://www.orafaq.com/wiki/DBMS_XMLGEN
It explains how to change the Oracle default names generated by the
DBMS_XMLGEN
package.The answer to your Question 1 is: it's the default values and behaviour for the Oracle DBMS_XMLGEN package
For Question 2: You would need to call some additional
DBMS_XMLGEN
procedures to alter the default values so you would need to use PL/SQL:Would output:
There are procedures to replace the
<ROWSET>
value with something more meaningful too.Hope it helps...