Skip to Main Content

SQL & PL/SQL

Announcement

Testing banner

Getting ORA-29280: invalid directory path while attempting to invoke utl_file

2769384Oct 14 2014 — edited Oct 15 2014

I have seen many posts on this, but none of the suggestions work. I have tried many variations of the following and I get pretty much the same error just on different lines. See below for the error.

My code is as follows:

  CREATE OR REPLACE DIRECTORY LOAD_SRC AS 'C:\Stuff\BulkInsert';

--select * from all_directories where directory_name = 'LOAD_SRC'; C:\Stuff\BulkInsert is in the list

    DECLARE

          sale_amount NUMBER;

          LOAD_SRC VARCHAR2(50); --If I don't add this I get the following msg: PLS-00201: identifier 'LOAD_SRC' must be declared

          FILE_HANDLE utl_file.file_type;

    BEGIN

    FILE_HANDLE := utl_file.fopen(LOAD_SRC,'stuff.dat','W',256);--29280. 00000 -  "invalid directory path"

      SELECT sum(sale_amount) INTO sale_amount FROM POS_RECORD;-- where sale_amount like '%-%';

      utl_file.put_line(FILE_HANDLE,sale_amount);

      utl_file.fclose(FILE_HANDLE);

    END;  

    / 

@@@@@@@@@@@@@@@@@@@@@@@

Error:

CREATE OR REPLACE DIRECTORY succeeded.

Error starting at line 3 in command:

DECLARE

          sale_amount NUMBER;

          LOAD_SRC VARCHAR2(50); --If I don't add this I get the following msg: PLS-00201: identifier 'LOAD_SRC' must be declared

          FILE_HANDLE utl_file.file_type;

    BEGIN

    FILE_HANDLE := utl_file.fopen(LOAD_SRC,'stuff.dat','W',256);--29280. 00000 -  "invalid directory path"

      SELECT sum(sale_amount) INTO sale_amount FROM POS_RECORD;-- where sale_amount like '%-%';

      utl_file.put_line(FILE_HANDLE,sale_amount);

      utl_file.fclose(FILE_HANDLE);

    END;  

   

Error report:

ORA-29280: invalid directory path

ORA-06512: at "SYS.UTL_FILE", line 41

ORA-06512: at "SYS.UTL_FILE", line 478

ORA-06512: at line 6

29280. 00000 -  "invalid directory path"

*Cause:    A corresponding directory object does not exist.

*Action:   Correct the directory object parameter, or create a corresponding

           directory object with the CREATE DIRECTORY command.

This post has been answered by Saubhik on Oct 14 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2014
Added on Oct 14 2014
7 comments
2,303 views