Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL*Plus: How can I write each record to a separate file

Re: SQL*Plus: How can I write each record to a separate file

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 08 Sep 2006 11:07:02 -0700
Message-ID: <1157738824.94196@bubbleator.drizzle.com>


zrwcvhsosoik001_at_sneakemail.com wrote:

> Well, the example is hypothetical of course. But UTL_FILE will not
> work, because I need the output on the client. We have no access to the
> server filesystem.
> 
> DA Morgan wrote:

>> 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 Group
  1. Please do not top post. Scroll to the bottom before replying.
  2. Good. I am glad your SAs and DBAs have kept everyone off the servers
  3. If you want this to write to the client machine ... then the version of Oracle, the front-end tools, and many other factors come into play: None of which you have disclosed.
  4. And I still think it sounds like a bad idea. What is the business case? -- Puget Sound Oracle Users Group
Received on Fri Sep 08 2006 - 13:07:02 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US