Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write SELECT output to a file from stored procedure

Status
Not open for further replies.

hayo

MIS
Sep 14, 2001
56
DE
I want to write the output from an Select statement to file, and I want to do that from a stored procedure in Oracle 8.1.7.

Does anybody know how to do that ?

Thanks
Hayo
 

You can make use of UTL_FILE oracle package.

example;

create or replace procedure write_sample
is
fh utl_file.file_type;
i number(4);
begin
fh := utl_file.fopen('/tmp/test.dat','test','w');
for rec in (select field1 from table1) loop
utl_file.put_line(fh,rec.field1);
end loop;
utl_file.fclose(fh);
end;
/
Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top