ITPub博客

首页 > 数据库 > Oracle > oracle utl_file

oracle utl_file

原创 Oracle 作者:maojinyu 时间:2011-01-26 11:44:04 0 删除 编辑

create or replace directory gp
as 'c:gp';

grant read, write on directory gp to mao

declare
f utl_file.file_type;
begin
f := utl_file.fopen('GP', 'something.txt', 'w');
for i in 1..100 loop
utl_file.put_line(f, 'line one: some text');
utl_file.put_line(f, 'line two: more text');
end loop;
utl_file.fclose(f);
end;

declare
f utl_file.file_type;
buf VARCHAR2(200);
v_id varchar2(20);
BEGIN
f := utl_file.fopen('GP', 'test.txt', 'R');
LOOP
utl_file.get_line(f, buf);
v_id := substr(buf, 1, 5);
dbms_output.put_line(v_id);
END LOOP;
utl_file.fclose(f);
exception
when others then
null;
END;

[@more@]

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

上一篇: 行列转换
下一篇: plsql插入图片
请登录后发表评论 登录
全部评论

注册时间:2012-05-09

  • 博文量
    178
  • 访问量
    376683