UTL_FILE invalid file operation

I am having this code to extract images from oracle Db to a folder but i am getting the following error
01:49:53 Error: ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 17

--create or replace directory my_dir as '/export/home/haruser/Desktop/Images';
DECLARE
v_dir varchar2(10):='MY_DIR';
t_blob BLOB;
t_len NUMBER;
t_file_name VARCHAR2(100);
t_output UTL_FILE.file_type;
t_TotalSize number;
t_position number := 1;
t_chucklen NUMBER := 4096;
t_chuck raw(4096);
t_remain number;
BEGIN
SELECT DBMS_LOB.getlength (IMAGE), brid || '_1.jpg'
INTO t_TotalSize, t_file_name FROM SA.T_CLIENTIDENTIFICATIONS WHERE BRID ='0000024' AND IMAGEID='4';
t_remain := t_TotalSize;
t_output := UTL_FILE.fopen (v_dir, t_file_name, 'wb', 32760);
SELECT IMAGE INTO t_blob FROM SA.T_CLIENTIDENTIFICATIONS WHERE BRID ='0000024' AND IMAGEID='4';
WHILE t_position < t_TotalSize
LOOP
DBMS_LOB.READ (t_blob, t_chucklen, t_position, t_chuck);
UTL_FILE.put_raw (t_output, t_chuck);
UTL_FILE.fflush (t_output);
t_position := t_position + t_chucklen;
t_remain := t_remain - t_chucklen;
IF t_remain < 4096
THEN
t_chucklen := t_remain;
END IF;
END LOOP;
END;

Anyone with solution where i could be doing wrong?
Muzurl FrancenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
My guess is the file already exists on the disk and Oracle doesn't have permissions on it.

Remove the file and try again.
0
Muzurl FrancenAuthor Commented:
Thanks for feedback, However i have removed the file and added but still the same error
0
slightwv (䄆 Netminder) Commented:
Does the oracle user have write permission in the folder?

The file IO is done as the oracle user since it is performed by the database itself and not the user executing the PL/SQL.

If the create directory path is the same, as the oracle user can you do:
touch /export/home/haruser/Desktop/Images/mytest.txt

If not, that is the problem.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Muzurl FrancenAuthor Commented:
I just assigned permission 777 to the folder and it worked.
0
slightwv (䄆 Netminder) Commented:
>> just assigned permission 777 to the folder

That probably isn't a good solution since that also enables EVERYONE full access to the folder.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.