5 Replies Latest reply on Mar 11, 2010 8:14 AM by 730428

    utl_file.frename -- renaming file

      I am trying to rename a file and is not working. I do have write access to the directory.

      utl_file.frename('/trans/CARDS/dev','abc_EXT.LOG', '/trans/CARDS/dev','x.log',TRUE);
      END frename;

      I am seeing the error message :

      ERROR at line 1:
      ORA-29280: invalid directory path
      ORA-06512: at "SYS.UTL_FILE", line 336
      ORA-06512: at "SYS.UTL_FILE", line 1214
      ORA-06512: at line 2

      any ideas?
        • 1. Re: utl_file.frename -- renaming file

          Oracle recommends using directory objects instead of actual paths (see this link for the 11gR2 documentation). Perhaps the paths you specified are not specified in the utl_file_dir parameter? Directory objects provide more flexibility than utl_file_dir usage. Use them if you can.

          Also, you stated that you had write permissions to the directory. The Oracle software owner, typically the oracle user, is the user that needs the permissions.

          Edited by: rbglossip on Mar 10, 2010 7:09 PM
          • 2. Re: utl_file.frename -- renaming file
            We are using oracle 10g release 1.

            I can write the file to the specified directory, If I can do that, why I cant i rename the file to some other name?

            • 3. Re: utl_file.frename -- renaming file
              I'm assuming you are using utl_file to write the file.

              Checking the documentation for error 29280, seems frename might not accept actual paths and expects directory objects instead. I know fopen supports paths for backward compatibility, not sure about frename. Can you use a directory object instead?
              • 4. Re: utl_file.frename -- renaming file
                user5679956 wrote:
                I am trying to rename a file and is not working.
                Perhaps you should read how this API call works and what the parameters are, instead of guessing?

                Oracle® Database PL/SQL Packages and Types Reference guide describes this all as follows (http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#i1003641):
                location      The directory location of the source file, a DIRECTORY_NAME from the ALL_DIRECTORIES view (case sensitive).
                filename      The source file to be renamed.
                dest_dir      The destination directory of the destination file, a DIRECTORY_NAME from the ALL_DIRECTORIES view (case sensitive).
                dest_file     The new name of the file.
                overwrite     The default is FALSE.
                Where does it say you can simply slap a physical directory path on as call parameter for location? It specifically states that a dir object is needed.

                One of the very fundamentals for any programmer is to know what you are coding. This means knowing EXACTLY what the call does and what the parameters are, and what (if any) the response will be. Writing code based in guessing is one of the worse programming sins in my book (next to not modularising code design).
                • 5. Re: utl_file.frename -- renaming file
                  Use directories:
                  create directory DEV as 'trans/CARDS/dev';
                  utl_file.frename('DEV','abc_EXT.LOG', 'DEV','x.log',TRUE);
                  END frename;