要操作文件,必須先建立你所操作的文件目錄
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
有貓相伴的日子 閱讀(1132)
評論(0) 編輯 收藏 所屬分類:
pl/sql