UTL_FILE [message #234214] |
Mon, 30 April 2007 08:26  |
janardhanam.k
Messages: 29 Registered: April 2007
|
Junior Member |
|
|
i want to read a table and put its contents into a file.
iam using the following code:
1CREATE OR REPLACE procedure p_write_file
2 is
3 cursor cur_all_dates is
4 select * from all_dates;
5 fileHandler UTL_FILE.FILE_TYPE;
6 begin
7 dbms_output.put_line('hi');
8 fileHandler := UTL_FILE.FOPEN('MYDIR', 'myfile', 'w');
9 for cur_rec in cur_all_dates loop
10 UTL_FILE.PUTF(fileHandler,cur_rec);
11 end loop;
12 UTL_FILE.FCLOSE(fileHandler);
13 EXCEPTION
14 WHEN utl_file.invalid_path THEN
15 raise_application_error(-20000, 'ERROR: Invalid path for file or path not in INIT.ORA.');
16
17 when others then
18 dbms_output.put_line('error');
19 end;
/
iam getting error at line 10.Can any one help me in this regard.Thanks in advance.
[Updated on: Mon, 30 April 2007 08:46] Report message to a moderator
|
|
|
Re: UTL_FILE [message #234227 is a reply to message #234214] |
Mon, 30 April 2007 09:05   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
What is the error that you are getting?
If the ALL_DATES table has more than one column, then trying to pass the whole row to UTL_FILE at once will certainly cause an error.
|
|
|
|
Table type [message #234872 is a reply to message #234227] |
Thu, 03 May 2007 06:46   |
janardhanam.k
Messages: 29 Registered: April 2007
|
Junior Member |
|
|
Hi,
The following code is giving this error at the line dbms_output.put_line.
CREATE OR REPLACE procedure test as
cursor abc is
select Day d
from all_dates;
type xyz_type is table of abc%rowtype
index by binary_integer;
xyz xyz_type;
begin
open abc;
fetch abc bulk collect into xyz;
for i in 1..10 loop
dbms_output.put_line(to_char(xyz(i)));
end loop;
end;
/
can any one help?
Thanks,
Jana
|
|
|
Re: Table type [message #234878 is a reply to message #234872] |
Thu, 03 May 2007 06:55  |
 |
Michel Cadot
Messages: 68737 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
See my answer in your other post.
Don't multipost.
Format your post.
Give your Oracle version.
Give the error message.
...
Regards
Michel
|
|
|