Showing posts with label Directories. Show all posts
Showing posts with label Directories. Show all posts

Tuesday, October 02, 2007

ORA-29289: directory access denied

You attempted to perform an operation like that contained in the following script:
declare
file_handle utl_file.file_type;
begin
file_handle := utl_file.FOpen('TEST_DIR', 'test.txt', 'w');
utl_file.put_line(file_handle, 'test');
utl_file.FFlush(file_handle);
utl_file.FClose(file_handle);
end;
/

ORA-29289: directory access denied
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at line 4
Note that we opened the file for writing, but the same applies when the file is opened for reading.

The error message simply means that you are not authorized to write (or read) in the target directory that is you lack the WRITE privilege (or the READ privilege) on the directory object being used.
The good news is that directory TEST_DIR is actually existing, otherwise you'd get ORA-29280.

You can fix the problem by asking the DBA to issue:
GRANT READ ON DIRECTORY TEST_DIR TO username
-- or
GRANT WRITE ON DIRECTORY TEST_DIR TO username
This error message means also that you do not hold the CREATE ANY DIRECTORY privilege, because if you held it, you could read and/or write to any directories that you created or even to those created by other users.

Without CREATE ANY DIRECTORY privilege, another user must create the directories for you (typically the DBA) and explicitly grant read and/or write privileges before you can successfully open a file located there.

You can easily determine if you are allowed to create directory objects yourself:

select privilege from user_sys_privs
/

PRIVILEGE
---------
CREATE PROCEDURE
CREATE JOB
CREATE TYPE
CREATE SYNONYM
CREATE CLUSTER
CREATE TABLE
CREATE ANY DIRECTORY
CREATE VIEW
CREATE SESSION
CREATE TRIGGER
CREATE SEQUENCE
CREATE MATERIALIZED VIEW

So, with this system privilege, it's possible to execute the following script without the need of asking the DBA to grant the write permission on TEST_DIR:
create directory test_dir as 'C:\Temp'
/* replace C:\Temp with any suitable path for your platform or environment */
/
declare
file_handle utl_file.file_type;
begin
file_handle := utl_file.FOpen('TEST_DIR', 'test.txt', 'w');
utl_file.put_line(file_handle, 'test');
utl_file.FFlush(file_handle);
utl_file.FClose(file_handle);
end;
/
Without the CREATE ANY DIRECTORY privilege, the first statement would fail with ORA-01031: insufficient privileges.

Note also that directory names specified in UTL_FILE procedures are case sensitive.
See the posting on ORA-29280 for further examples on this subject.

Last but not least, once you pick the directory object method for specifying file system paths for read/write operations, you no longer need to worry about the setting of parameter UTL_FILE_DIR.

See message translations for ORA-29289 and search additional resources.



ORA-29289: accesso alla directory negato
ORA-29289: acceso al directorio denegado
ORA-29289: s'ha denegat l'accés al directori
ORA-29289: accès refusé au répertoire
ORA-29289: Verzeichniszugriff abgelehnt
ORA-29289: δεν επιτρέπεται η πρόσβαση στον κατάλογο
ORA-29289: katalogadgang nægtet
ORA-29289: åtkomst till katalogen nekad
ORA-29289: ingen tilgang til katalog
ORA-29289: ei hakemiston käyttöoikeutta
ORA-29289: a könyvtárhoz való hozzáférés megtagadva
ORA-29289: accesarea directorului a fost refuzată
ORA-29289: Toegang tot directory is geweigerd.
ORA-29289: acesso ao diretório negado
ORA-29289: acesso ao directório recusado
ORA-29289: отказ в доступе к каталогу
ORA-29289: přístup k adresáři byl zamítnut
ORA-29289: prístup do adresára odmietnutý
ORA-29289: odmowa dostępu do katalogu
ORA-29289: dizine erişim reddedildi
ORA-29289: directory access denied

Tuesday, April 18, 2006

ORA-29280

ORA-29280: invalid directory path
Cause: A corresponding directory object does not exist.

For some reason i have been postponing the search of the real reasons behind this error message until i finally found some spare time in my busy agenda.

At first it was a bit frustrating because i had two allegedly identical systems running the same software and behaving in two different fashions, that is the ideal scenario for one of those nasty situations that may depend on some factor like "different letter case" or boundary conditions.

In my case it proved to be the latter, being an oracle initialization parameter the culprit.

As you certainly know, starting from version 9, directory objects have been introduced in order to hold information about file system folders in an easily manageable way.

Instead of tampering with the initialization file and the UTL_FILE_DIR parameter, which is almost obsolete, and forces you to bounce the database in case of changes, you can easily handle file system pointers by means of directories.

Now, suppose that in version 10g you want to use an utility like UTL_FILE.FREMOVE, that allows you to delete a file from the file system, provided you have the necessary privileges.
If you set UTL_FILE_DIR to * (or to a specific list of directories) in the spfile, you can still pass the full directory path (e.g. '/tmp/files') as location parameter to FREMOVE.
If UTL_FILE_DIR is not set, the only way to reference a file is by means of a directory object pointing to the folder where the file is located.

In my humble opinion both the description of the cause of error message and the description of the location parameter have not been explained very clearly because they never mention the possibility of getting different results depending on the value of UTL_FILE_DIR.

Clearly it has been made this way in order to keep the software compatible with previous versions of Oracle but, for some reason, it was not so obvious for me.

Updated October 2, 2007

It's worth noting that you can get ORA-29280 also when you supply the directory object name using the wrong letter casing:
create directory test_dir as 'C:\Temp'
/
is not the same as
create directory "test_dir" as 'C:\Temp'
/
Indeed the former statement will create a directory object TEST_DIR (uppercase identifier) whereas the latter will create a lowercase one.
This has some consequences in the way you specify the directory name in UTL_FILE parameters that are case sensitive and also in the GRANT statements where you must enclose the identifier in double quotes.

Likewise the path content may or may not be case sensitive depending on the platform, i guess that it's case insensitive on Windows and it's case sensitive on Unix, so watch out for the letter casing!



ORA-29280: percorso della directory non valido
ORA-29280: ruta de acceso del directorio no válida
ORA-29280: ruta d'accés del directori no vàlida
ORA-29280: chemin de répertoire non valide
ORA-29280: Ungültiger Verzeichnispfad
ORA-29280: Μη αποδεκτή διαδρομή καταλόγου
ORA-29280: ugyldig katalogsti
ORA-29280: ogiltig katalogsökväg
ORA-29280: ugyldig katalogbane
ORA-29280: virheellinen hakemistopolku
ORA-29280: érvénytelen könyvtárútvonal
ORA-29280: cale de director nevalidă
ORA-29280: Ongeldig directorypad
ORA-29280: caminho de diretório inválido
ORA-29280: percurso do directório inválido
ORA-29280: недопустимый путь доступа к каталогу
ORA-29280: neplatná cesta k adresáři
ORA-29280: neplatná cesta adresára
ORA-29280: niepoprawna ścieżka katalogu
ORA-29280: geçersiz dizin yolu

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles