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

Home -> Community -> Usenet -> c.d.o.server -> Re: UTL_FILE code example

Re: UTL_FILE code example

From: Martin Haltmayer <Martin_Haltmayer_at_in.augsburg.net>
Date: Sun, 05 Sep 1999 15:09:50 +0200
Message-ID: <37D26B9E.4AC24B1F@in.augsburg.net>

  1. In your init.ora file you have to specify a list of directories where utl_file is allowed to access, e. g. utl_file_dir = '/tmp' on Unix or utl_file_dir = 'D:\TEMP' on Windows NT. Shutdown and restart your instance with this parameter set properly.
  2. I use the directory path d:\temp.

declare

	f utl_file.file_type;
	cursor c1 is
	select emp_name,emp_dept,emp_salary from employee;
begin
	f:= utl_file.fopen ('d:\temp', 'example.txt', 'w');
	for r in c1 loop
		utl_file.put_line (f, r.emp_name || r.emp_dept || r.emp_salary);
	end loop;
	utl_file.fclose (f);
exception
	when others then
	if (utl_file.is_open (f)) then
		utl_file.fclose (f);
	end if;
	raise;

end;
/

Martin

prakbala_at_hotmail.com wrote:
>
> Will someone please give me an example of how to write
> a file out using UTL_FILE function ?
>
> For ex:
>
> cursor c1 is
> Select emp_name,emp_dept,emp_salary from employee;
>
> I would like to write this info to a flat file. Also I would
> like to know what changes I need to make in ORAINIT file for
> default UTL_FILE directory of C:\flatfile.
>
> Thank You.
>
> PB
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Sun Sep 05 1999 - 08:09:50 CDT

Original text of this message

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