Home » SQL & PL/SQL » SQL & PL/SQL » how to create a directory on init.ora file? (Oracle 8i or 10g)
how to create a directory on init.ora file? [message #564052] Tue, 21 August 2012 02:22 Go to next message
victoryhendry
Messages: 85
Registered: January 2007
Location: Bangalore
Member

I have to create some flat files in Oracle server and before started creating files I have done below steps.

1)
CREATE OR REPLACE DIRECTORY public_access AS '/xyz/public_access';
GRANT read, write ON DIRECTORY public_access TO public;

2) CONNECT test/test;

DECLARE
f1 UTL_FILE.FILE_TYPE;
BEGIN
f1 := UTL_FILE.FOPEN('PUBLIC_ACCESS','exists.dat','w');
UTL_FILE.FCLOSE(f1);
END;
/


but my requirement is, I should not create any directory in explicitly, since it will be problem while changing the oracle server. Hence, I have to be created in init.ora file.

Please suggest me on this with example, how we can do it with init.ora file?

Thanks and Regards,

Vetrivel K. (Oracle - Dpi)
Re: how to create a directory on init.ora file? [message #564055 is a reply to message #564052] Tue, 21 August 2012 02:56 Go to previous messageGo to next message
Michel Cadot
Messages: 58860
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous topics:

cookiemonster wrote on Mon, 12 March 2012 11:33
@victoryhendry - Will you please read and follow How to use [code] tags and make your code easier to read? You've been asked several times before.
...


Quote:
Michel Cadot wrote on Tue, 06 March 2012 11:50
Michel Cadot wrote on Mon, 20 February 2012 10:51
Michel Cadot wrote on Mon, 20 February 2012 10:24
With all SQL questions, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.
...

...

...



Quote:
Michel Cadot wrote on Wed, 22 February 2012 09:41
@ victoryhendry,

and it is NOT formatted.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel


Quote:
Please suggest me on this with example, how we can do it with init.ora file?


Very bad idea, directories are there to protect you, better create the directory as you want for each server. What is the difference between setting a parameter in init.ora and creating a directory?

Note that in 8i directories did not exist but this version no more exists itself.

Regards
Michel
Re: how to create a directory on init.ora file? [message #564121 is a reply to message #564052] Tue, 21 August 2012 08:42 Go to previous message
Solomon Yakobson
Messages: 1994
Registered: January 2010
Senior Member
victoryhendry wrote on Tue, 21 August 2012 03:22
but my requirement is, I should not create any directory in explicitly, since it will be problem while changing the oracle server.


Your requirement makes no sense. Yes, Oracle still (for compatibility) supports old way of UTL_FILE security where list of directories UTL_FILE is allowed to work with is listed in init.ora parameter utl_file_dir. But it will not make your code transparent. Assume you go utl_file_dir route. Then your code will be:

f1 := UTL_FILE.FOPEN('/xyz/public_access','exists.dat','w');


Now if you install your app to another server where files need to be written to a different directory you will change init.ora and specify new directory, e.g. '/xyz/new_public_access' in utl_file_dir. But it will not do you any good. Still, you will have to modify the above code to

f1 := UTL_FILE.FOPEN('/xyz/new_public_access','exists.dat','w');


And you will have to do such changes everywhere in your code where directory is referenced. As you can see, no matter what you will have to make code changed when OS directory changes. But with directory object code changes are localized to a single point of recreating directory object while with utl_file_dir solution (obsolete by itself) you will have to modify init.ora and ALL places where directory is referenced. As you can see, your reqs are forcing you into a worse and obsolete solution comparing to correct oracle directory object solution you use now.

SY.
Previous Topic: auto increment
Next Topic: dos2unix
Goto Forum:
  


Current Time: Fri Aug 22 03:40:02 CDT 2014

Total time taken to generate the page: 0.08487 seconds