日期:2014-05-17  浏览次数:20895 次

如果在存储过程中将查询的结果集生成一个xml文件?
比如:
select   *   from   all_tables

使用sql语句将上面的查询结果生成到D:\oracle_AllTables.xml  
?


本来是想通过程序来处理,但是,这样还的性能太低,


------解决方案--------------------
SELECT XMLELEMENT( "Department ",
XMLAGG(XMLELEMENT( "Employee ",
e.job_id|| ' '||e.last_name)
ORDER BY last_name))
as "Dept_list "
FROM employees e
WHERE e.department_id = 30;

Dept_list
-------------------------
<Department>
<Employee> PU_CLERK Baida </Employee>
<Employee> PU_CLERK Colmenares </Employee>
<Employee> PU_CLERK Himuro </Employee>
<Employee> PU_CLERK Khoo </Employee>
<Employee> PU_MAN Raphaely </Employee>
<Employee> PU_CLERK Tobias </Employee>
</Department>
然后再把查询结果用流写出来