Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';
Then your user (myuser in this example) will use that directory object inside your FOPEN statement e.g.
GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.
fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');
965328 wrote:So you're happy for your systems to have security holes in them.... very odd. Oracle does not recommend using deprecated functionality, so the developers should be using the correct tool for the job, and that IS directory objects.
Thank you for the reply.I know it's an old thread. I should have open a new one :)
I know it's deprecated with Oracle 10g versions.
But sometimes developers does not want to go with the new changes.
Can you please still answer my original question reg the UTL_FILE_DIR?In the hours that have passed since you posted the question, you could have tested it. I can't recall if * was a special case in it's own right or whether it could be part of a directory path.... and I was wrong, it's not since 10g, it's actually since 9i R1...