utl_file

create directory utl_path as '/home/oracle/';
grant read,write on directory utl_path to scott;
grant execute on utl_file to scott;
conn scott/tiger
declare
v_hand_file utl_file.file_type;
cursor cur_dept is select * from dept;
begin
v_hand_file := utl_file.fopen('UTL_PATH','dept'||trunc(sysdate)||'.txt','w',32767);
for v_cur_dept in cur_dept loop
utl_file.put_line(v_hand_file,v_cur_dept.deptno||','||v_cur_dept.dname||','||v_cur_dept.loc);
end loop;
utl_file.fclose(v_hand_file);
end;
/
create table dept_01 as select * from dept where 1=2;
declare
v_hand_file utl_file.file_type;
v_text varchar2(1000 char);
v_first number;
v_second number;
v_deptno dept_01.deptno%type;
v_dname dept_01.dname%type;
v_loc dept_01.loc%type;
begin
v_hand_file := utl_file.fopen('UTL_PATH','dept11-NOV-12.txt','r');
loop
begin
utl_file.get_line(v_hand_file,v_text);
exception
when no_data_found then
exit;
end;
dbms_output.put_line(v_text);
commit;
end loop;
end;
/

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23382569/viewspace-761071/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23382569/viewspace-761071/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值