[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Invalid operation when using utl_file fopen

Posted on 2000-03-02
5
Medium Priority
?
3,640 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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