ITPub博客

首页 > Linux操作系统 > Linux操作系统 > utl_file

utl_file

原创 Linux操作系统 作者:cdbdp 时间:2013-05-14 21:44:49 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/23382569/viewspace-761071/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: DBMS_ERRLOG
下一篇: dbms_job
请登录后发表评论 登录
全部评论

注册时间:2010-02-22

  • 博文量
    51
  • 访问量
    105410