Solved

Invalid operation when using utl_file fopen

Posted on 2000-03-02
5
3,627 Views
Last Modified: 2012-08-14
I'm encountering an invalid operation error when using utl_file fopen. The directory I'm trying to write to is listed properly in the utl_file_dir parm in init.ora and we've verified the read / write permissions on the Unix operating system. Not sure what else could cause this. Any info would be appreciated.

Thanks.
Richard.
0
Comment
Question by:rlwremo
  • 3
5 Comments
 
LVL 6

Expert Comment

by:mshaikh
ID: 2577484
Make sure that you can login in to the uinx box with the 'oracle' OS user account and do a cd to the dir in question and also check if you can actually create a file there. Also, make sure that you don't have the sticky bit set.
0
 
LVL 4

Accepted Solution

by:
jtrifts earned 25 total points
ID: 2579721
I have experienced the same problem onn occasion.  There are several things to consider:

1. Oracle must be able to see the directory.  Thus the utl_file_dir must have the FULL location or '*'.  Remeber, Unix is case sensitive, so the case of path is essential.

2. Applicable privileges on the directory and file must be granted to the Oracle user.

3. The file name and path in the procedure using utl_file must be accurate:
DECLARE
v_location          VARCHAR2(200) := '/users/app/oracle/product/8.1.5/admin/Data_Location';
v_filename          VARCHAR2(200) := 'your_data_file.dat' ;
   v_file_handle       UTL_FILE.FILE_TYPE;
BEGIN
   v_file_handle := UTL_FILE.FOPEN(v_location,v_filename,'r');

LOOP ...

I have found the most common errors to be with the utl_file_dir (which you say you have already checked), and the wrong case of the location of the file.

Unfortunately, invalid_operation seems to be a catchall for FOPEN, even though technically, FOPEN can raise many different errors.

Can you confirm that the both the case of the file directory (in both utl_file_dir and in the calling procedure) and the file name referenced in the calling procedure all have the correct case?

One point on security: If you set utl_file_dir to * and don't have strict directory and/or file permissions within your unix structures, you leave yourself open to others breaking in via Oracle and grabbing and or writing data).


0
 
LVL 4

Expert Comment

by:jtrifts
ID: 2579753
ONe more thing...the database server is on the same unix box as the file you're looking for, right?
0
 

Author Comment

by:rlwremo
ID: 2579836
Well,

It turns out that it was a permissions problem. Even though we opened up permissions all the way (I think 777 is the term) those permissions didn't cascade down to existing files. Just on a whim I deleted the file we were trying to use and found that the permissions were still set to a more limiting profile. After that, our write routine was able to recreate the file with no error.

Thanks to all who responded!

Richard.
0
 
LVL 4

Expert Comment

by:jtrifts
ID: 2579857
Glad to be of service!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question