Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: UTL_FILE Oracle object
On Tue, 29 Jun 1999 20:32:30 +0200, Talko Dijkhuis
<DijkhuisT_at_Vertis.nl> wrote:
Add some exception code to trap the error, and then you can determine the cause.
i.e. Something like this (untested):
EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('no_data_found');
UTL_FILE.FCLOSE(v_FileHandle);
return(0);
WHEN UTL_FILE.INVALID_PATH THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.INVALID_PATH'); UTL_FILE.FCLOSE(v_FileHandle);
return(0);
WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(' OTHER: ' || SQLCODE || ' ' ||SQLERRM ); UTL_FILE.FCLOSE(file_handle);
return(0);
end;
A common error is not having the
utl_file_dir = <directory>
setting in your INIT.ORA file. In your case it looks like it would be:
utl_file_dir = C:\sql
Then you would need to shutdown and restart Oracle.
Hope this helps,
Brian
>select your directory from v$parameter so is the directory changes in
>the init file you don't have to rewrite your statement
>
>"A. el Azzouzi" wrote:
>
>> Hello there,
>>
>> I want to use the UTL_FILE oracle object to open a file, write, and
>> then close it.
>>
>> But upon opening of the file, I get some errors.
>> Can somebody tell me what is wrong with the next
>> statement:
>>
>> v_FileHandle UTL_FILE.FILE_TYPE;
>> ....
>> v_FileHandle := UTL_FILE.FOPEN('c:\sql\', 'output.txt', 'w');
>> ...
>>
>> Is the syntax for opening the file ok?
>>
>> Any reaction is welcome,
>>
>> A. el Azzouzi
Received on Thu Jul 01 1999 - 12:59:36 CDT
![]() |
![]() |