Database PL/SQL ORA-29280:无效的目录路径和ORA-06512:at";SYS.UTL_文件;在oracle 11g中
我只想使用Database PL/SQL ORA-29280:无效的目录路径和ORA-06512:at";SYS.UTL_文件;在oracle 11g中,database,oracle,plsql,oracle11g,Database,Oracle,Plsql,Oracle11g,我只想使用UTL\u file概念将表数据写入文本文件 i) 创建了一个新目录: Create directory ddd as 'D:\sql'; ii)授予用户HR对该目录的读写访问权限: grant read,write on directory ddd to hr; iii)授予其他UTL_文件权限: grant execute on UTL_FILE to hr; 我编写了程序,得到的错误如下: SQL> connect hr/admin Connected.
UTL\u file
概念将表数据写入文本文件
i) 创建了一个新目录:
Create directory ddd as 'D:\sql';
ii)授予用户HR对该目录的读写访问权限:
grant read,write on directory ddd to hr;
iii)授予其他UTL_文件权限:
grant execute on UTL_FILE to hr;
我编写了程序,得到的错误如下:
SQL> connect hr/admin
Connected.
SQL> declare
2 f utl_file.file_type;
3 i varchar(100);
4 begin
5 f:=utl_file.fopen('ddd','utlfile.txt','w',32767);
6 for x in(select first_name,salary from employees where rownum<=10)loop
7 i:=x.first_name||' '||x.salary;
8 utl_file.put_line(f,i);
9 utl_file.new_line(f);
10 end loop;
11 utl_file.fclose(f);
12 end;
13 /
我不知道我在这里错过了什么。。。。我为这个问题挣扎了大约两天。请帮助我。我们使用的变量定义为
char
而不是varchar2
,因此它在文件名中填充空格。目录名大写,请尝试DDD
而不是DDD
declare
*
ERROR at line 1:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 41
ORA-06512: at "SYS.UTL_FILE", line 478
ORA-06512: at line 5