Click to See Complete Forum and Search --> : Writing to a file using UTL_FILE


cpb123
May 25th, 2004, 11:16 AM
Hi,

I am trying write information to a text file using PL/SQL. I have the following code run from a post-text-item trigger:

DECLARE

firstline DATE := :TREATMENT.treatment_date;
output_file utl_file.file_type;

BEGIN

output_file := utl_file.fopen ('C:/', 'drugDetails.txt', 'W');

utl_file.put_line(output_file, firstline);
utl_file.fclose(output_file);

END;

I recieve this error:
FRM-40735: POST-TEXT-ITEM trigger raised unhandled exception ORA-06510

Please can somebody tell me where im going wrong, or is there an easier way to go about it?

Thank you for your time

Gabriel Fleseriu
May 26th, 2004, 08:20 AM
You have to tell Oracle that it is allowed to write in that directory. You do this by adding an utl_file_dir line to your init???.ora file:

utl_file_dir="C:\..."