将 XML 格式的数据插入 Oracle 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6263387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Inserting Data in XML into Oracle database
提问by manish
My task is to get data from One database (non oracle db) and insert that data into another database(oracle).
我的任务是从一个数据库(非 oracle db)获取数据并将该数据插入另一个数据库(oracle)。
I am able to get the data from the source database in the form of XML. Now I have to pass this XML as input to the oracle database so that all the data inside the XML is inserted into the oracle database table.
我能够以 XML 的形式从源数据库中获取数据。现在我必须将此 XML 作为输入传递给 oracle 数据库,以便将 XML 中的所有数据插入到 oracle 数据库表中。
Can some one please guide me as what is the code for doing the same. I am quite used to SQL Server 2005.
有人可以指导我做同样的事情的代码是什么。我很习惯 SQL Server 2005。
If some one can guide with how insert data in XMl into a table, it would be of great help.
如果有人可以指导如何将 XML 中的数据插入到表中,那将是非常有帮助的。
回答by StevieG
This is as generic as I can make it without seeing the xml structure..
这是通用的,因为我可以在没有看到 xml 结构的情况下做到这一点。
create or replace procedure put_stuff_into_table(source_xml_doc xmltype) AS
BEGIN
insert into table (a, b)
select *
from xmltable('<TOP_LEVEL_ELEMENT>'
passing source_xml_doc
columns a number path 'ELEMENT_TAG_A',
b varchar2(100) path 'ELEMENT_TAG_B'
);
END;
/