Oracle的UTL_FILE.FOPEN学习笔记
时间:2021-07-01 10:21:17
帮助过:39人阅读
<http://lveyo.javaeye.com/blog/351416>
create or replace procedure PRO_TO_TXT(FILE_OWNER VARCHAR2,FILE_NAME VARCHAR2)
is
file_handle utl_file.file_type;
STOR_TEXT VARCHAR2(4000);
N NUMBER;
I NUMBER;
begin
I:=1;
SELECT MAX(LINE) INTO N FROM ALL_SOURCE WHERE OWNER=‘‘ || FILE_OWNER || ‘‘ AND NAME=‘‘ || FILE_NAME || ‘‘ AND TYPE= ‘PROCEDURE‘;
file_handle:=utl_file.fopen( ‘/oradata/procedure_bak‘, ‘zhfx117.txt‘, ‘A‘);
utl_file.put_line(file_handle, ‘PROCEDURE NAME: ‘||FILE_NAME);
WHILE I <=N LOOP
SELECT TEXT INTO STOR_TEXT FROM ALL_SOURCE WHERE OWNER=FILE_OWNER
AND NAME=FILE_NAME AND TYPE= ‘PROCEDURE‘ AND LINE= I;
I:=I+1;
utl_file.put_line(file_handle,stor_text);
END LOOP;
utl_file.fclose(file_handle);
commit;
end PRO_TO_TXT;
Oracle的UTL_FILE.FOPEN学习笔记
标签: