Friday, January 2, 2015

Solve ORA-29289: directory access denied error while using UTL_FILE

You have a stored procedure that use UTL_FILE to perform operations such as read, move files and directories. But executing the stored procedure gives you the error: ORA-29289: directory access denied error while using UTL_FILE. Here is how to solve it.



If you execute the script directly as

DECLARE
BEGIN
-- your code using UTL_FILE
END;
/

the script seems to work correctly, but if you wrap it into a stored procedure if gives you the ORA-29289 error, like that:

CREATE OR REPLACE
PROCEDURE "MY_PROCEDURE"
AS
BEGIN
-- your code using UTL_FILE
END;

So, to solve this, simply add AUTHID CURRENT_USER option to your procedure declaration, like this:

CREATE OR REPLACE 
PROCEDURE "MY_PROCEDURE"
AUTHID CURRENT_USER
AS
BEGIN
-- your code using UTL_FILE
END;

And it should now work correctly.


1 comment:

(c) Copyright 2020 - MyTroubleshooting.com