【问题标题】:DB2 Import (Raw) XML DataDB2 导入(原始)XML 数据
【发布时间】:2016-11-07 14:47:17
【问题描述】:

有没有办法将原始 xml 数据导入(或加载)到具有 xml 类型列的表中。

<customerinfo Cid="1000"><name>Kathy Smith</name><addr country="Canada"><street>5 Rosewood</street><city>Toronto</city><prov-state>Ontario</prov-state><pcode-zip>M6W 1E6</pcode-zip></addr><phone type="work">416-555-1358</phone></customerinfo>
<customerinfo Cid="1001"><name>Kathy Smith</name><addr country="Canada"><street>25 EastCreek</street><city>Markham</city><prov-state>Ontario</prov-state><pcode-zip>N9C 3T6</pcode-zip></addr><phone type="work">905-555-7258</phone></customerinfo>
...

xml 文档的每一行都应该排成一行。

import from C:\temp\test.xml OF DEL INSERT INTO XMLCOLUMN

DB2 正确读取 XML 文件,但未能将其导入行...

Number of rows read = 6
Number of rows skipped = 0
Number of rows inserted = 0
Number of rows updated = 0
Number of rows rejected = 6
Number of rows = 6

有什么想法吗?

【问题讨论】:

  • 一个想法可能是检查实际的错误消息,准确地解释为什么这些行被拒绝。
  • 我基本上说它缺少一个 xsd 文件

标签: xml import db2 load db2-luw


【解决方案1】:

您需要有一个 DEL 文件,其中包含有关在何处查找 XML 文件的说明。尝试类似:

test.del:

<XDS FIL='test.xml' />

如果您有其他列,则上述 XDS 将是其他值旁边的常规列值。

test.xml:你的 XML 文件

然后

import from test.del OF DEL INSERT INTO MyTable

“MyTable”是您的带有 XML 列的表。有关更多示例,请参阅DB2 docs

【讨论】:

  • 是的,据说没有导入原始 xml 数据的选项...但是谢谢。
  • 您可以导入原始 XML,但需要通过 CSV 文件解决方法。如果您只想导入 XML 数据,我见过可以生成 CSV 的脚本。
猜你喜欢
  • 2013-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-22
  • 1970-01-01
  • 2022-01-15
  • 2021-06-16
相关资源
最近更新 更多