| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Who to use package utl_file ?
On Wed, 09 Sep 1998 15:12:28 +0200, "E. van Diermen"
<diermene_at_ce.philips.nl> wrote:
>Hay ye'all
>
>I have the following problem/question:
>- How can I create a (e.g. text) file in pl/sql (stored procedure) ?
>(e.g. c:\temp\temp.txt)???
>
>It is easy to create this in a library with the text_io package, but
>this package is of course not usable in a stored procedure...so, use the
>utl_file. But this package gives errors when I want to use it:
>
>SQL> declare
> 2 ft utl_file.file_type;
> 3 begin
> 4 ft := utl_file.fopen('C:\temp\','temp.txt','w');
> 5 end;
> 6 /
>declare
>*
>ERROR at line 1:
>ORA-06510: PL/SQL: unhandled user-defined exception
>ORA-06512: at "SYS.UTL_FILE", line 82
>ORA-06512: at "SYS.UTL_FILE", line 120
>ORA-06512: at line 4
I belive your unhandeled exception is an exception defined in UTL_FILE package: EXCEPTION UTL_FILE.INVALID_PATH. You can verify this by including this exception handler into your code.
If you set "UTL_FILE_DIR = *" (read about the security issues regarding this setting!) in your init<SID>.ora, you'll get your file "c:\temp\temp.txt" on the server, if such directory exists.
If you set "UTL_FILE_DIR = C:\temp", then you must not use the last trailing backslash when specifying the path in your call to UTL_FILE.FOPEN, e.g.
ft := utl_file.fopen('C:\temp','temp.txt','w');
Remember also that specified path must mach the path in UTL_FILE_DIR parameter *exactly*. It is case sensitive, although you are on Windows environment, which is generaly case insensitive.
>Can anyone help me with this? Am I using the utl_file package
>improperly??
>
>Erwin
HTH,
--
Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)
![]() |
![]() |