Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create a physical OS directory using PL/SQL.

user13363562Sep 22 2012 — edited Sep 22 2012
Hi,

I need to create a physical OS directory using PL/SQL.

When tried the below code

CREATE OR REPLACE PROCEDURE APPS.xx_CreateDir (dirname VARCHAR) is
myfile utl_file.file_type;
buf VARCHAR2(20) := 'TEST';
stmt_cre_dir VARCHAR2(200):= 'CREATE OR REPLACE DIRECTORY ATTACHMENT_DIR AS ' || '''' ||dirname|| '''';
BEGIN
EXECUTE IMMEDIATE stmt_cre_dir;
myfile := utl_file.fopen('DIR','test.dat','w');
utl_file.put(myfile, buf);
utl_file.fclose(myfile);
EXCEPTION
WHEN others THEN
dbms_output.put_line(sqlcode || ' ' || sqlerrm);
END;
/

its not creating a physical directory.

Kindly help me solve this issue.

Thanks,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2012
Added on Sep 22 2012
14 comments
3,774 views