要操作文件,必须先建立你所操作的文件目录
CREATE DIRECTORY    peidw   AS  '/tmp/peidw';
下面代码是读取并遍历一个文件
procedure createdatafile 
as
 file_handle2 UTL_FILE.FILE_TYPE;
 data_line varchar2(80);
begin
  file_handle2:=UTL_FILE.fopen('PEIDW','t.txt','r');
  loop
    begin
      utl_file.get_line(file_handle2,data_line);
      dbms_output.put_line(data_line);
    exception
       when   no_data_found   then   exit;  
   end;
  end loop;
  dbms_output.put_line('OK');
  utl_file.fclose(file_handle2);
end createdatafile;
写入的方法也差不多,使用utl_file.output()等方法
select name||chr(9)||'cc'||chr(10)||'dd' cname  from tt_job
chr(9),是tab键编码
char(10),换行的编码
用于生成CVS文件挺方便
	
posted on 2007-09-05 16:32 
有猫相伴的日子 阅读(1140) 
评论(0)  编辑  收藏  所属分类: 
pl/sql