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: How can I write on a file?

Re: How can I write on a file?

From: Tim Steiger <tsteiger_at_ctron.com>
Date: 1997/09/09
Message-ID: <3415744C.114E0775@ctron.com>#1/1

More than likely, the problem is that you need an entry in your initorcl.ora in the database directory under ORACLE_HOME like so:

UTL_FILE_DIR = C:\SOME_DIR This allows users to access this directory for reading and writing.

One more note, you can trap the error by adding an exception section like so:
DECLARE
...
BEGIN
...
EXCEPTION
  WHEN UTL_FILE.INTERNAL_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('INTERNAL_ERROR');   WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    DBMS_OUTPUT.PUT_LINE('INTERNAL_ERROR');   WHEN UTL_FILE.INVALID_MODE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_MODE');   WHEN UTL_FILE.INVALID_OPERATION THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_OPERATION');   WHEN UTL_FILE.INVALID_PATH THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_PATH');   WHEN UTL_FILE.READ_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('READ_ERROR');   WHEN UTL_FILE.WRITE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('WRITE_ERROR');   WHEN VALUE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('VALUE_ERROR'); END; For further explanation of these errors, see the Oracle7 Server Application Developer’s Guide Page 8 - 31

I hope this helps...

Tim

Pepe Galindo wrote:

> hello!
>
> Why do not write the following PL/SQL program?
>
> ----------------
> DECLARE
> CURSOR query IS SELECT atributo FROM TABLA;
> fich UTL_FILE.FILE_TYPE;
>
> BEGIN
> fich:=UTL_FILE.FOPEN('users','pprueba.sql','w');
> FOR item IN query LOOP
> UTL_FILE.PUT_LINE(fich,item.atributo);
> END LOOP;
> UTL_FILE.FCLOSE(fich);
> END;
> /
> ----------------
>
> Error message:
> ORA-06510: PL/SQL: unhandled user-defined exception.
> ORA-06512: at "SYS.UTL_FILE", lines 82 and 120.
>
> I work in a PC with Personal Oracle. Thanks!
>
> ppgg_at_lcc.uma.es
Received on Tue Sep 09 1997 - 00:00:00 CDT

Original text of this message

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