2uzhan.com
Advertisement
Now Place:2uzhan.com » Error while accessing files in server through plsql

Error while accessing files in server through plsql

Database @ February 7, 2007   Views:0

Hello All,

I have to access files using PLSQL.
I have set the initialization parameter utl_file_dir as follows:

SQL> select value from v$parameter where name='utl_file_dir';

VALUE
--------------------------------------------------------------------------------
/u08/reports/

I have written a small procedure to write into a file as follows:

create or replace procedure test_file(filedir in varchar2,filename in varchar2) as
FFile UTL_FILE.FILE_TYPE;
BEGIN
BEGIN
FFile := utl_file.fopen(filedir,fileName,'W');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error');
END;
utl_file.put_line(ffile,'===========');
END test_file;

When I have called the above procedure using the below PLSQL block:

begin
test_file('/u08/reports','test.rpt');
end;

I got the error as:
ORA-29282: invalid file ID
ORA-06512: at "SYS.UTL_FILE", line 714
ORA-06512: at "GENEVA_ADMIN.TEST_FILE", line 18
ORA-06512: at line 5

Can anyone plz let me know where the problem is?

--------------Solutions-------------

This could help:

http://utplsql.sourceforge.net/Doc/admin.html

HTH,
Krzemo.

Hi all.

You have to set Oracle parameter 'UTL_FILE_DIR' to directory where you want read or write; you can set this parameter to '*', that means all directories.
You must be sure to have read/write permission on directories.

Hello All,

The problem is solved.

I am using Oracle 9.
At oracle 9, If I am not wrong the utl_file_dir will be obsolete and we have to use database objects for accessing the files in the server through plsql.

So, When I used the database objects then I can able to wite into files that are located on the server.

This utl_file_dir is used at Oracle 8.

Thanks,
prashas_d.

Tags:
© 2018 2uzhan.com Contact