Re: pl/sql question - how to create multiple files- reg

From: Paul Druker <pdruker_at_metaway.com>
Date: Tue, 04 Apr 2000 04:27:51 GMT
Message-ID: <bbeG4.1089$d13.23679_at_typhoon.southeast.rr.com>


Rathan,

I don't think it's a problem. You need to declare a couple of variables:

  g_utl_handle UTL_FILE.FILE_TYPE;   g_utl_name varchar2(50);

and repeat the following for each dept:

  g_utl_name := <your> file_name;
  g_utl_handle := utl_file.fopen('/tmp',g_utl_name,'w');   utl_file.put_line(g_utl_handle,'........');   utl_file.fclose(g_utl_handle);

Thanks,
Paul

"RATHANB" <rathanb_at_cs.com> wrote in message news:20000403235055.27825.00000744_at_ng-ba1.news.cs.com...
> Hi all
> I have to create 20-30 different flat files using UTL_FILE utility.
> I am looking for some good logic, how do I create 20-30 files
> dynamically.
> For example, I have a main cursor which selects many departments and
> employess in those departments. For each department fetched I have to
> create a file with department name and employees, the problem is when
> I write code like below:
> declare
> cursor c1 is select dept_no,emp_no from emp_master;
> begin
> for c1 in c1_cur
> loop
> file_name = c1_cur.dept_no;
> create the file using UTL_FILE;
> write all the employee info into the file ;
> ?????
> end loop;
> when there is dept change within the loop, firstly how do I understand
> it is different new dept_no compare to previous dept_no fectched, and
> then how do i create a second different dept_no file..and continue for the
dept
> numbers fetched dynamically (it could be 1 or 20) with in the cursor.
> can I use any counters etc.,
> I am looking for prefered logic to find how I understand it is different
> dept_no,
> and proceed with creation of another dept_no file; I am aware of UTL_FILE
> stuff;only thing is logic to create many files depending on dept_no
change;
> is that i need to create table and load the cursor values or give me a
> good suggestion.
>
> Thanks
> Rathan.
>
Received on Tue Apr 04 2000 - 06:27:51 CEST

Original text of this message