简体   繁体   English

DB2 SQL XMLSERIALIZE / Select 的 XML 值 *

[英]DB2 SQL XMLSERIALIZE / XML value of Select *

I would like to output all fields of a SELECT SQL in DB2 as XML.我想将 DB2 中 SELECT SQL 的所有字段输出为 XML。 Sorry for using "Select *" here but in this case it makes sense.很抱歉在这里使用“Select *”,但在这种情况下它是有道理的。 Have checked XMLSERIALIZE and XMLELEMENT commands but they need a field list.已检查 XMLSERIALIZE 和 XMLELEMENT 命令,但它们需要一个字段列表。 eg例如

SELECT XMLELEMENT (*) as X from DATA1.CUSTOMERS where CUSTOMERNO='262627'

or或者

SELECT  XMLSERIALIZE (*) as X from DATA1.CUSTOMERS where CUSTOMERNO='262627'

does not work.不起作用。 Can you help me?你能帮助我吗?

There is no XML publishing function that accepts the wildcard.没有接受通配符的 XML 发布功能。 The easiest way would be to use XMLROW .最简单的方法是使用XMLROW It accepts a column list or more complex expressions and gives you some options for the final format.它接受列列表或更复杂的表达式,并为您提供一些最终格式的选项。

select xmlrow(col1, col2) from mytable

or或者

select xmlrow(col1, col2 option row "myrowname") from mytable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM