我在oracle9i中读取文本文件的内容,
declare
input_file utl_file.file_type;
buff varchar2(400);
begin
input_file := utl_file.fopen('read_text','d:\abc\a.txt','r');
loop
utl_file.get_line(input_file,buff);
dbms_output.put_line(buff);
end loop;
utl_file.fclose(input_file);
exception
when no_data_found then
dbms_output.put_line('----------------');
end;我已经创建了一个read_text目录了,
create directory read_text as 'd:\abc';
而且在abc下有一个a.txt文件。
为什么报错啊:
ora_29280:目录路径无效
declare
input_file utl_file.file_type;
buff varchar2(400);
begin
input_file := utl_file.fopen('read_text','d:\abc\a.txt','r');
loop
utl_file.get_line(input_file,buff);
dbms_output.put_line(buff);
end loop;
utl_file.fclose(input_file);
exception
when no_data_found then
dbms_output.put_line('----------------');
end;我已经创建了一个read_text目录了,
create directory read_text as 'd:\abc';
而且在abc下有一个a.txt文件。
为什么报错啊:
ora_29280:目录路径无效
已写入 file afiedt.buf 1 declare
2 input_file utl_file.file_type;
3 buff varchar2(400);
4 begin
5 input_file := utl_file.fopen('d:\abc','a.txt','r');
6 loop
7 utl_file.get_line(input_file,buff);
8 dbms_output.put_line(buff);
9 end loop;
10 utl_file.fclose(input_file);
11 exception
12 when no_data_found then
13 dbms_output.put_line('----------------');
14* end;
SQL> /
declare
*
第 1 行出现错误:
ORA-29280: 目录路径无效
ORA-06512: 在 "SYS.UTL_FILE", line 29
ORA-06512: 在 "SYS.UTL_FILE", line 448
ORA-06512: 在 line 5
SQL> alter system set UTL_FILE_DIR ='d:\abc' SCOPE=spfile;系统已更改。
SQL> conn / as sysdba
已连接。
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。Total System Global Area 535662592 bytes
Fixed Size 1334380 bytes
Variable Size 289407892 bytes
Database Buffers 239075328 bytes
Redo Buffers 5844992 bytes
数据库装载完毕。
数据库已经打开。
SQL> edit
已写入 file afiedt.buf 1 declare
2 input_file utl_file.file_type;
3 buff varchar2(400);
4 begin
5 input_file := utl_file.fopen('d:\abc','a.txt','r');
6 loop
7 utl_file.get_line(input_file,buff);
8 dbms_output.put_line(buff);
9 end loop;
10 utl_file.fclose(input_file);
11 exception
12 when no_data_found then
13 dbms_output.put_line('----------------');
14* end;
SQL> /
fdjlasjfdldsjlf
----------------PL/SQL 过程已成功完成。SQL>
这句,
能解释一下吗?
必须先创建一个Oracle文件夹,通过这个文件夹访问,
建立文件夹的方法很简单,你在google一搜就知道了。
还是应该多东东脑子好点。