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

如何将oracle读取里面的数据生成XML
求类似这样的工具下载 多谢了

------解决方案--------------------
1、CREATE DIRECTORY WORKIT_DIR AS 'd:\workit';
2、grant read,write on directory workit_dir TO WORKIT;
3、
DECLARE
input_file UTL_FILE.FILE_TYPE;
input_buffer VARCHAR2(4000);
result CLOB;
xmlstr VARCHAR2(32767);
BEGIN
result := DBMS_XMLQuery.getXml('SELECT *
FROM t_student where rownum<5');
xmlstr := DBMS_LOB.SUBSTR(result,32767);
input_file := UTL_FILE.FOPEN( 
'WORKIT_DIR', 'EMP.xml', 'W');

LOOP
EXIT WHEN xmlstr IS NULL;
input_buffer := SUBSTR(xmlstr,1,INSTR(xmlstr,CHR(10))-1);
UTL_FILE.PUT_LINE(input_file,input_buffer);
xmlstr := SUBSTR(xmlstr,INSTR(xmlstr,CHR(10))+1);

END LOOP;
UTL_FILE.FCLOSE(input_file);
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('------------------');

END;
/

------解决方案--------------------
,应该是这个图片,发现上个图片显示不正确,好像是路径问题。