测试的过程如下:
- drop directory MTR_UTL_FILE_DIR ;
- create or replace directory MTR_UTL_FILE_DIR as '/tmp';
- grant read,write on directory MTR_UTL_FILE_DIR to apps;
- select * from dba_directories;
1.创建文件
- declare
- fhandle utl_file.file_type;
- begin
- fhandle := utl_file.fopen('MTR_UTL_FILE_DIR', 'MIS_OUT_F1_NO.txt', 'w');
- utl_file.put_line(fhandle , '123 \'||'诶砂杰芝灰膛次 '||'mm');
- utl_file.put_line(fhandle , '456 '||'诶砂杰芝灰 '||'mm');
- utl_file.fclose(fhandle);
- end;
- /
- declare
- fhandle utl_file.file_type;
- fp_buffer varchar2(4000);
- begin
- fhandle := utl_file.fopen ('MTR_UTL_FILE_DIR','MIS_OUT_F1_NO.txt', 'R');
-
- utl_file.get_line (fhandle , fp_buffer );
- dbms_output.put_line(fp_buffer );
- utl_file.get_line (fhandle , fp_buffer );
- dbms_output.put_line(fp_buffer );
- utl_file.fclose(fhandle);
- end;
- /
3.在操作系统中检查该文件。
[root@szodbd01 tmp]# cat MIS_OUT_F1_NO.txt
123 璇剁犳璋璎? mm
456 璇剁犳璋 mm
[root@szodbd01 tmp]#
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23757700/viewspace-1065603/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23757700/viewspace-1065603/