Home » SQL & PL/SQL » SQL & PL/SQL » invalid file operation (Oracle 12C , IBM AIX)
icon5.gif  invalid file operation [message #662678] Tue, 09 May 2017 09:03 Go to next message
Durai_1
Messages: 2
Registered: May 2017
Junior Member
I am getting the below error while trying to create a file in unix box using sqlplus. Can anyone have idea how to resolve this?

SQL>declare
v_buff VARCHAR2(2000);
fhandle UTL_FILE.FILE_TYPE;
begin
dbms_output.put_line('WRITE');
fhandle:= UTL_FILE.FOPEN('HHT_DIR','Report.txt','W');
UTL_FILE.put_line(fhandle,' Attempt to write');
UTL_FILE.FCLOSE(fhandle);
end;
/
2 3 4 5 6 7 8 9 10 declare
*
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 6
Re: invalid file operation [message #662680 is a reply to message #662678] Tue, 09 May 2017 09:19 Go to previous messageGo to next message
BlackSwan
Messages: 25796
Registered: January 2009
Location: SoCal
Senior Member
It works OK for me.
  1  declare
  2  v_buff VARCHAR2(2000);
  3  fhandle UTL_FILE.FILE_TYPE;
  4  begin
  5  dbms_output.put_line('WRITE');
  6  fhandle:= UTL_FILE.FOPEN('LOG_FILE_DIR','Report.txt','W');
  7  UTL_FILE.put_line(fhandle,' Attempt to write');
  8  UTL_FILE.FCLOSE(fhandle);
  9* end;
SQL> /

PL/SQL procedure successfully completed.


Re: invalid file operation [message #662681 is a reply to message #662680] Tue, 09 May 2017 09:32 Go to previous messageGo to next message
Durai_1
Messages: 2
Registered: May 2017
Junior Member
Hi,

But in my machine I am getting this particular error. I want to know why it is throwing this error

-Durai
Re: invalid file operation [message #662682 is a reply to message #662681] Tue, 09 May 2017 09:44 Go to previous messageGo to next message
Solomon Yakobson
Messages: 2697
Registered: January 2010
Location: Connecticut, USA
Senior Member
Is "my machine" database server or database resides on a different server?

SY.
Re: invalid file operation [message #662690 is a reply to message #662678] Tue, 09 May 2017 10:38 Go to previous messageGo to next message
EdStevens
Messages: 888
Registered: September 2013
Senior Member
What does this query reveal:

select * from dba_directories where directory_name='HHT_DIR';

And does the OS directory shown by DIRECTORY_PATH actually exist?

It is a common misconception that creating a directory object in the db also creates the OS directory on disk. It doesn't.
Re: invalid file operation [message #662692 is a reply to message #662681] Tue, 09 May 2017 11:08 Go to previous message
BlackSwan
Messages: 25796
Registered: January 2009
Location: SoCal
Senior Member
Durai_1 wrote on Tue, 09 May 2017 07:32
Hi,

But in my machine I am getting this particular error. I want to know why it is throwing this error

-Durai
error is thrown because the FOPEN fails.

If you can't debug posted code, then consider you might not have the capacity to be a PL/SQL programmer.
Previous Topic: Produce output not having any or all inputs (products)
Next Topic: Decode and To_date
Goto Forum:
  


Current Time: Fri Jan 19 16:37:09 CST 2018

Total time taken to generate the page: 0.03556 seconds