gvenzl / oci-oracle-free

Build scripts for Oracle Database FREE container/docker images
Apache License 2.0
113 stars 28 forks source link

Unable to produce file on container's file system using UTL_FILE #50

Open cartbeforehorse opened 1 month ago

cartbeforehorse commented 1 month ago

Thank you for this project - it's a great resource. However, I have a problem with Utl_File generating output.

I've created a new directory on the file system as /opt/oracle/oradata/share. It has 777 privilege.

Then on the database I create an Oracle directory: create or replace directory EXCEL_OUT as '/opt/oracle/oradata/share';

Then I execute the following code

DECLARE
   file_ Utl_File.File_Type;
   txt_  VARCHAR2(256) ;
BEGIN
   file_ := Utl_File.fOpen ('EXCEL_OUT', 'abc.txt', 'w');
   txt_  := 'testing' ;
   Utl_File.put_LINE( file_, txt_);
   Utl_File.Putf (file_, '%s  %s %s \n', txt_, 'test', '123');
   Utl_File.fFlush (file_);
   dbms_output.put_line('line is: ' || txt_) ;
   Utl_File.fClose(file_);
END;

It executes fine. >> PL/SQL procedure successfully completed.

But no abc.txt file is created. Wondering if I'm missing something silly.

For what it's worth, the directory /opt/oracle/oradata/share is mounted to my host's file system. But I don't think that's a significant factor. I can't write to any directory in the container's file-system.

cartbeforehorse commented 1 month ago

Scratch this. It may have been a case of my being overzealous with some Docker start commands. I deleted the problematic container and started again afresh with a new instance. It seems to work on my second attempt.