Home » SQL & PL/SQL » SQL & PL/SQL » utl_file : invalid_path error
utl_file : invalid_path error [message #270169] Wed, 26 September 2007 00:48 Go to next message
Messages: 1
Registered: September 2007
Location: india
Junior Member
hello buddies !!

I am getting problem with writing the flat file using utl_file

I have created directory in the database server and grated all
privileges and also set the utl_file_dir into init.ora file.

when I execute this procedure I get invalid path error.

create or replace procedure sal_status(p_filedir in varchar2,p_filename in varchar2) is

v_filehandle utl_file.file_type;

cursor emp_info is select last_name,salary,department_id from

employees order by department_id;

v_newdeptno employees.department_id%type;

v_olddeptno employees.department_id%type := 0;


v_filehandle := utl_file.fopen(p_filedir,p_filename,'w');

utl_file.putf(v_filehandle,'salary report : generated on %s\n',sysdate);


for v_emp_rec in emp_info loop

v_newdeptno := v_emp_rec.department_id;

if v_newdeptno <> v_olddeptno then

utl_file.putf(v_filehandle,'department : %s\n',v_emp_rec.department_id);

end if;

utl_file.putf(v_filehandle,' employee: %s earns: %s\n',v_emp_rec.last_name,v_emp_rec.salary);

v_olddeptno := v_newdeptno;

end loop;

utl_file.put_line(v_filehandle,'*** end of report ***');



when utl_file.invalid_path then dbms_output.put_line('Invalid Path');

when utl_file.invalid_filehandle then

raise_application_error(-20001,'Invalid file');

when utl_file.write_error then

raise_application_error(-20002,'unable to write to file');

end sal_status;

Re: utl_file : invalid_path error [message #270170 is a reply to message #270169] Wed, 26 September 2007 00:52 Go to previous message
Michel Cadot
Messages: 65137
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

Previous Topic: cursor parameters
Next Topic: pair date range from 2 tabs
Goto Forum:

Current Time: Thu Aug 17 08:49:10 CDT 2017

Total time taken to generate the page: 0.06664 seconds