Solved

Invalid operation when using utl_file fopen

Posted on 2000-03-02
5
3,620 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
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…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now