mardi 2 juin 2015

Writing a file to a custom created directory on Oracle Amazon-RDS

I can connect to the database via sqlplus

sqlplus stepdba/<password>@steprds.<rds-hash-here>.<region>.rds.amazonaws.com:1521/STEP

and I am trying to write to a file.

According to AmazonRDS documentation regarding Oracle, create directory must be done with rdsadmin.rdsadmin_util.create_directory('MY_DIR'); which I have done.

To write to a file, I do the following:

DECLARE
    fileHandler UTL_FILE.FILE_TYPE;
BEGIN
   fileHandler := UTL_FILE.FOPEN('MY_DIR', 'test.txt', 'W');
   UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
   UTL_FILE.FCLOSE(fileHandler);
END;
/

Which result in an error:

ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 4

If I try to write to an Oracle provided directory DATA_PUMP_DIR, the above snippet executes correctly and the file is written.

The privileges to the two directories are the same

select grantee, privilege from dba_tab_privs where table_name='DATA_PUMP_DIR' and grantee = 'STEPDBA';
select grantee, privilege from dba_tab_privs where table_name='MY_DIR' and grantee = 'STEPDBA';

In the Amazon-RDS case, we can not manipulate the file/directory permissions on the OS level.

I seem to be missing something, any hint would be appreciated.




Aucun commentaire:

Enregistrer un commentaire