我在谷歌上搜索了"如何在oracle文件中存储xml文件"
但是,我还没有找到任何解决方案
我想存储一个xml文件(原始数据)。我不想要BFile
请告诉我存储xml和从Oracle数据库检索的方法。
谢谢。
要存储XML文件,可以使用BLOB类型的列。这只会为您存储数据。要使用PLSQL访问XML文件,请使用BFILE。然后可以将文件加载到BLOB列中。
以下是一些示例:http://dwarehouse.wordpress.com/2011/06/15/loading-and-unloading-files-using-oracle-database/
或者,您可以使用客户端编程语言提供的任何方法。
从外部XML中选择属性值
您可以从外部XML文件中的任何标记中提取值并插入数据库,但您将面临一些问题,根据我使用oracle的经验,请注意以下几点:
- oracle的配置文件包含一些默认的名称空间,所以如果您的xml文件中有任何名称空间,否则这些名称空间,您必须将其添加到您构建的过程或函数中
- 如果您从XML(BLOB或CLOB文件)中进行选择,请不要忘记将结果转换为格式化为XML的BLOB或CLOB
下面是一个使用从XML文件中返回的值的过程更新表的示例
CREATE OR REPLACE procedure Test(FileName in varchar,URN_Par in varchar)
is
begin
update Test
set File_Name =(
------------------this step get value of tag (file_name) and update test table , also you have to write any namespaces in as below
select
extract(column_value, '//File_Name/text()','xmlns="http://tempuri.org/')
from
table(xmlsequence(xmltype(bfilename('GIDTEMPFILES',FileName) ,
nls_charset_id('AL16UTF8')))))
, Class_Name =(
select
extract(column_value, '//Class_Name/text()','xmlns="http://tempuri.org/')
from
table(xmlsequence(xmltype(bfilename('GIDTEMPFILES',FileName) ,
nls_charset_id('AL16UTF8')))))
, Document_Date =(
select
extract(column_value, '//Document_Date/text()','xmlns="http://tempuri.org/')
from
table(xmlsequence(xmltype(bfilename('GIDTEMPFILES',FileName) ,
nls_charset_id('AL16UTF8')))))
, Image =(
-------------return the value stored in the image tag as clob to column image in DB which is clob
select
extract(column_value, '//Image/text()','xmlns="http://tempuri.org/').GetClobVal()
from
table(xmlsequence(xmltype(bfilename('GIDTEMPFILES',FileName) ,
nls_charset_id('AL16UTF8')))))
where URN = URN_par;
end;