0

work with UTL_FILE. I want to create a file in 'G:\'. I create a directory with:

create or replace directory XYZ as 'G:\';

grant read, write on directory XYZ to hr;

declare
  fp utl_file.file_type;
  CURSOR c1 is select EMPLOYEE_ID, FIRST_NAME, SALARY from employees;
begin
  fp :=utl_file.fopen('xyz','file1.txt','w');
  for i in c1
  loop
    utl_file.put_line(fp,i.EMPLOYEE_ID||' '||i.FIRST_NAME||' '||i.SALARY);
  end loop;
  utl_file.fclose(fp);
end;
/

When I execute the procedure I get the error:

ORA-29280: invalid directory path

Alex Poole
  • 183,384
  • 11
  • 179
  • 318
  • is G:\ your local directory ,you may refer this thread https://stackoverflow.com/questions/60882726/utl-file-saving-in-local-machine/60883518#60883518 – psaraj12 Apr 05 '20 at 14:56
  • Is the Oracle server you are connected to running on your own PC, or is it a remote server? – Bob Jarvis - Слава Україні Apr 05 '20 at 15:16
  • 2
    Also the directory name in the `fopen` clause has to match the case of the object name in the data dictionary; from what you've shown (though the names have probably been changed) that should be `utl_file.fopen('XYZ', ...)` not `'xyz'`. – Alex Poole Apr 05 '20 at 16:05
  • 1
    utl_file runs on the database serer, not the client. Is this drive local or on the server? – OldProgrammer Apr 05 '20 at 16:32

0 Answers0