oracle存储过程执行中输出日志文件

create or replace procedure p_outputdebug(a varchar2,b varchar2,c varchar2)
is
vFileName varchar2(100);
OutputFile UTL_FILE.FILE_TYPE;
begin
select 'rfid_'||a.rfid||'.log'
into vFileName
from tbl_animal_info a where a.rfid='330100000078176'

;
OutputFile := utl_file.fopen('background_dump_dest',vFileName,'a');
utl_file.putf(OutputFile,a,b,c);
utl_file.fflush(OutputFile);
utl_file.fclose(OutputFile);
end ;


SQL> create or replace directory "background_dump_dest"as 'D:\database\cares100\bdump';

Directory created

SQL> grant read on directory "background_dump_dest" to myuser;

Grant succeeded

SQL> grant write on directory "background_dump_dest" to myuser;

Grant succeeded

SQL> call myuser.p_outputdebug('1','1','1');

Method called

--需要注意的一点是:日志目录需创建在oracle所在服务器上,否则报错。

posted @ 2016-05-07 13:30  李清欣  阅读(16124)  评论(0编辑  收藏  举报