Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL*Plus: How can I write each record to a separate file
zrwcvhsosoik001_at_sneakemail.com wrote:
> Hi,
>
> I need to select a set of records, and then write each record to a
> separate file.
> Something like this (in pseudo code). The idea is to write the salary
> of each employee to a separate file with the name of the employee.
>
> FOR rec in select * from emp LOOP
> create file with filename rec.ename
> write rec.sal to file
> close file
> END LOOP
>
> Is this possible using SQL*Plus? Or would you recommend another tool.
>
> Thanks!
Use UTL_FILE. You can find a demo of this in Morgan's Library at www.psoug.org. You will need to modify it, however, to create each individual file and name it.
I wonder how well this has been thought out from the business requirements standpoint. You are going to end up with a lot of separate files sitting on the server (where no one should be mucking about) that will then need to be moved or further processed. Why not just go directly to whatever end result is desired?
-- Daniel Morgan University of Washington Puget Sound Oracle Users GroupReceived on Fri Sep 08 2006 - 07:51:45 CDT
![]() |
![]() |