ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORACLE中Directory的使用及应注意的问题

ORACLE中Directory的使用及应注意的问题

原创 Linux操作系统 作者:jack22220613 时间:2010-05-20 18:00:14 0 删除 编辑

注:我在例子中用的是scott用户,oracle版本为  9.2.0.1

首先,先授予用户scott的相应directory权限

grant create any directory to scott;

grant drop any dirctory to scott;(删除权限)

 

其次,创建directory

create or replace directory report_dir as 'd:\temp';

 

然后,使用该directory

create or replace procedure bulk_rowtype is
  f utl_file.file_type;
begin
  f := utl_file.fopen('REPORT_DIR','report.dat','W');
  for i in (select * from t) loop
    utl_file.put_line(f,'a='||i.a||',b='||i.b||',c='||i.c||',d='||i.d);
  end loop;
  utl_file.fclose(f);

end;

/

特别强调: f := utl_file.fopen('REPORT_DIR','report.dat','W');
该句中,report_dir 应写成大写 REPORT_DIR,否则会提示

ORA-29280: 目录路径无效

最后提示:在oracle9.2版本中utl_file不再使用utl_file_dir参数。

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

请登录后发表评论 登录
全部评论

注册时间:2009-05-13

  • 博文量
    94
  • 访问量
    385657