SQL加载器问题
我尝试通过 SQL Loader 从 XML 文件加载到 Oracle 中的一些列为空。例如,可能有几个已填充,但偶尔会有一些空值。
我如何告诉 SQL*Loader 某些数据将为空,或者如何处理空值?
Some of the columns that I am trying to load into Oracle via SQL Loader from an XML file are null. For example may have several filled but ocassionally it has some nulls.
How can I tell the SQL*Loader that some of the data will be null, or how can I deal with nulls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就像乔尼尔斯建议的那样。我使用 XMLTABLE 将 XML 数据插入到关系表中。首先将 XML 数据放入 Oracle 表 XMLTYPE 列中:
使用 XMLTable 函数创建(或插入)表:
Like jonearles suggested. I use XMLTABLE to insert XML data into relational tables. First put the XML data into a Oracle tables XMLTYPE column:
Use XMLTable function to create (or insert into) the table:
您可能需要重新考虑加载和转换文件的方式。我认为这与您的其他问题有关,在这种情况下,您似乎正在构建您自己的 XML 解析器。 Oracle 提供了一些工具来帮助您做到这一点。
首先,要加载文件,您可以 使用SQL*Loader 以 XMLType 的形式加载数据,或者您可以使用 DBMS_XSLPROCESSOR.READ2CLOB 之类的内容以 CLOB 的形式读取文件,然后将其转换为 XMLType。
加载为 XMLType 后,您可以使用 PL/SQL 过程,该过程使用 XPath 来迭代这些值并将它们插入到表中。
可能还有其他一些方法可以做到这一点。
我确信这些想法都不像您所希望的那么简单。正确处理 XML 比 SQL*Loader 通常用于加载分隔文件要复杂得多。
You may want to rethink the way you're loading and transforming files. I assume this is related to your other question, in which case it looks like you're building your own XML parser. Oracle provides some tools to help you do this.
First, just to load the file, you can either use SQL*Loader to load the data as an XMLType, or you can use something like DBMS_XSLPROCESSOR.READ2CLOB to read the file as a CLOB and then convert it to an XMLType.
After it's loaded as an XMLType, you can use a PL/SQL procedure that uses XPath to iterate through the values and insert them into the table.
And there are probably some other ways to do it.
I'm sure none of these ideas are nearly as easy as what you were hoping for. Processing XML correctly is much more complicated than what SQL*Loader is typically used for - loading delimited files.