首页 > 数据库 > Oracle > oracle 写文件
----创建路径
create or replace directory pass_path as 'd:houxt';
----创建写的存储过程
create or replace procedure proc_write(num number)
is
---create or replace directory pass_path as 'd:houxt';
cursor cur_dat is
select pass_no||'|'||pass_word||'|'||cre_date||'|'||pass_state as jilu from user_pass@DCSYS251 t
where rownum<=num;
fhandle utl_file.file_type;
err varchar2(100);
begin
-----注意这里的路径名大写
fhandle := utl_file.fopen('PASS_PATH', 'pass.txt', 'w');
for dat in cur_dat loop
utl_file.put_line(fhandle ,dat.jilu);
end loop;
utl_file.fclose(fhandle);
exception when others then
err:=substr(sqlerrm,1,100);
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9307930/viewspace-1028824/ ,如需转载,请注明出处,否则将追究法律责任。