|
Re: Oracle UTL_FILE exception read_error [message #297243 is a reply to message #297232] |
Wed, 30 January 2008 15:19 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - Production
SQL>
1 declare
2 file_handle utl_file.file_type;
3 output_line varchar2(32767);
4 i number;
5 begin
6 i := 0;
7 file_handle := utl_file.fopen('TEST_DIR','test.txt','r');
8 loop
9 begin
10 utl_file.get_line(file_handle,output_line);
11 dbms_output.put_line('Line Number : ' || i || ' and length is : ' || length(output_line));
12 i := i + 1;
13 exception
14 when no_data_found
15 then
16 exit;
17 end;
18 end loop;
19 if utl_file.is_open(file_handle)
20 then
21 utl_file.fclose(file_handle);
22 end if;
23* end;
SQL> /
Line Number : 0 and length is : 54
Line Number : 1 and length is :
Line Number : 2 and length is : 80
Line Number : 3 and length is : 80
Line Number : 4 and length is : 80
Line Number : 5 and length is : 80
Line Number : 6 and length is : 80
Line Number : 7 and length is : 80
Line Number : 8 and length is : 80
Line Number : 9 and length is : 80
Line Number : 10 and length is : 80
Line Number : 11 and length is : 80
Line Number : 12 and length is : 80
Line Number : 13 and length is : 80
Line Number : 14 and length is : 80
Line Number : 15 and length is :
Line Number : 16 and length is : 80
Line Number : 17 and length is : 80
Line Number : 18 and length is : 80
Line Number : 19 and length is : 80
Line Number : 20 and length is : 80
Line Number : 21 and length is :
Line Number : 22 and length is : 19
Line Number : 23 and length is : 6
Line Number : 24 and length is :
declare
*
ERROR at line 1:
ORA-29284: file read error
ORA-06512: at "SYS.UTL_FILE", line 98
ORA-06512: at "SYS.UTL_FILE", line 656
ORA-06512: at line 10
1 declare
2 file_handle utl_file.file_type;
3 output_line varchar2(32767);
4 i number;
5 begin
6 i := 0;
7 file_handle := utl_file.fopen('TEST_DIR','test.txt','r', 32767);
8 loop
9 begin
10 utl_file.get_line(file_handle,output_line);
11 dbms_output.put_line('Line Number : ' || i || ' and length is : ' || length(output_line));
12 i := i + 1;
13 exception
14 when no_data_found
15 then
16 exit;
17 end;
18 end loop;
19 if utl_file.is_open(file_handle)
20 then
21 utl_file.fclose(file_handle);
22 end if;
23* end;
SQL> /
Line Number : 0 and length is : 54
Line Number : 1 and length is :
Line Number : 2 and length is : 80
Line Number : 3 and length is : 80
Line Number : 4 and length is : 80
Line Number : 5 and length is : 80
Line Number : 6 and length is : 80
Line Number : 7 and length is : 80
Line Number : 8 and length is : 80
Line Number : 9 and length is : 80
Line Number : 10 and length is : 80
Line Number : 11 and length is : 80
Line Number : 12 and length is : 80
Line Number : 13 and length is : 80
Line Number : 14 and length is : 80
Line Number : 15 and length is :
Line Number : 16 and length is : 80
Line Number : 17 and length is : 80
Line Number : 18 and length is : 80
Line Number : 19 and length is : 80
Line Number : 20 and length is : 80
Line Number : 21 and length is :
Line Number : 22 and length is : 19
Line Number : 23 and length is : 6
Line Number : 24 and length is :
Line Number : 25 and length is : 2000
Line Number : 26 and length is : 2000
Line Number : 27 and length is : 2000
Line Number : 28 and length is :
Line Number : 29 and length is : 57
Line Number : 30 and length is :
Line Number : 31 and length is : 2000
Line Number : 32 and length is : 2000
Line Number : 33 and length is : 2000
Line Number : 34 and length is :
Line Number : 35 and length is : 14
PL/SQL procedure successfully completed.
From next time could you please do the same like what I did.
Thanks
Raj
|
|
|
|
Re: Oracle UTL_FILE exception read_error [message #297572 is a reply to message #297247] |
Fri, 01 February 2008 07:06 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
before version
file_handle := utl_file.fopen('TEST_DIR','test.txt','r');
After version
file_handle := utl_file.fopen('TEST_DIR','test.txt','r', 32767);
Check the last parameter while opening a file. Default value is 1024 (i.e) it means You are telling oracle that I am not expecting more than 1024 characters in a line. I have changed it to maximum allowed 32767.
HTH
Regards
Raj
P.S : Spelling mistake corrected
[Updated on: Fri, 01 February 2008 07:07] Report message to a moderator
|
|
|
|
|
|