oracle生产xml文件夹,浅谈如何将Oracle导出到XML文件

以下操作在Oracle9i、10g版本成功

步骤一:创建存放XML文件的目录对象

SQL>createorreplacedirectoryexp_diras'/opt';/

--注意此目录要有oracle用户的写权限

步骤二:创建过程生成xml文件的主过程

SQL>createorreplaceproceduretable2xml(result inoutnocopyclob,filenameinvarchar2)isxmlstr varchar2(32767);line varchar2(2000);fhandle utl_file.file_type;beginfhandle := utl_file.fopen('EXP_DIR', filename,'w');xmlstr := dbms_lob.substr(result,32767);loopexitwhenxmlstrisnull;line := substr(xmlstr,1, instr(xmlstr, chr(10)) -1);dbms_output.put_line('| '|| line);utl_file.put_line(fhandle, line);xmlstr := substr(xmlstr, instr(xmlstr, chr(10)) +1);endloop;utl_file.fclose(fhandle);end;/

步骤三:调用此过程

declarequeryctx dbms_xmlquery.ctxType;result clob;beginqueryctx := dbms_xmlquery.newContext('select user_id,user_name from lq_xml_test');--存放查询记录集的SQLresult := dbms_xmlquery.getXML(queryctx);table2xml(result,'table2xml.xml');dbms_xmlquery.closeContext(queryctx);end;/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值