然後顯示錯誤。這裏的一些特殊字符有關的問題,所以我不能生成xml文件,這裏XML格式相同generate XML from oracle tables當我在存儲過程下運行時,從oracle表生成xml文件
Connecting to the database DB_old.
ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 148
ORA-06512: at "SYS.UTL_FILE", line 889
ORA-06512: at "DBO_17FEB.EXPOR1", line 60
ORA-06512: at line 6
Process exited.
Disconnecting from the database DB_old.
-------------------
create or replace
PROCEDURE Expor1
(
V_TABLE_NAME IN varchar2
)
AS
BEGIN
----- Export table data
DECLARE
v_file UTL_FILE.file_type;
qryCtx DBMS_XMLGEN.ctxHandle;
result CLOB;
result1 CLOB;
v_FILENAME varchar2(30);
BEGIN
IF UPPER(V_TABLE_NAME) = 'PROJECT' THEN
qryCtx := dbms_xmlgen.newContext ('SELECT * from '||V_TABLE_NAME ||'');
ELSIF UPPER(V_TABLE_NAME) = 'LOGFILE' THEN
qryCtx := dbms_xmlgen.newContext ('select LOG_ID, USER_ID,RUN_DATE,PROCESS,MPOID,MODE_,trim(STATUS) as STATUS,
trim(regexp_replace(unistr(NOTES), ''[[:punct:]] '','''')) as NOTES,
MARKDELETED from logfile where rownum<100 ');
ELSE
qryCtx := dbms_xmlgen.newContext ('SELECT * from '||V_TABLE_NAME ||'');
END IF;
v_FILENAME :=V_TABLE_NAME;
DBMS_XMLGEN.setMaxRows(qryCtx, 5);
v_file := UTL_FILE.fopen('MYXML', v_FILENAME || '.xml', 'W');
UTL_FILE.put_line(v_file, '<XML><'||v_FILENAME||'></'||v_FILENAME||'> <RECORDS>');
-- v_file := UTL_FILE.FOPEN('MYXML', v_FILENAME|| '.xml', 'R');
LOOP
DBMS_XMLGEN.SETNULLHANDLING(qryCtx ,null);
DBMS_XMLGEN.setRowSetTag(qryCtx, 0);
DBMS_XMLGEN.setRowTag(qryCtx, 'RECORD');
-- save the XML into the CLOB field
result := DBMS_XMLGEN.getXML(qryCtx);
--result := REPLACE(result, '<?xml version="1.0"?>','<XML><'||v_FILENAME||'>'||result1 ||'</'||v_FILENAME||'>');
result := REPLACE(result, '<?xml version="1.0"?>',' ');
result := REPLACE(result, '<_x0030_>',' ');
result := REPLACE(result, '</_x0030_>',' ');
--result :=trim(result);
-- UTL_FILE.put_line(v_file, '');
EXIT WHEN DBMS_XMLGEN.getNumRowsProcessed(qryCtx) = 0;
-- store the XML to a XML files
UTL_FILE.put_line(v_file, result);
--UTL_FILE.put_line(v_file, '</XML>');
END LOOP;
UTL_FILE.put_line(v_file, '</RECORDS></XML>');
UTL_FILE.FCLOSE(v_file);
END;
END Expor1;
i am not able to handle some special char like : &/; :/ . etc please help
您顯示的錯誤與您所說的問題不符;當你爲'LOGFILE'調用這個函數時,我假設你實際上仍然在使用ORA-31061? –