ORA-29280: Invalid directory path
573127Apr 20 2007 — edited Apr 20 2007Dear Sir,
I am having function which i wrote here at below, when i tried to execute this
using
begin
dbms_output.put_line(
load_data( 'T1',
'x,y,z',
'log_dir',
'emp2.dat',
',' ) || ' rows loaded' );
end;
It's giving me the error message
ORA-29280: Invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at "OTSLGDW.LOAD_DATA", line 17
ORA-06512: at line 2
As i am using 10g.
Even though i created the directory called "log_dir" using
create or replace directory LOG_DIR
as 'D:\chandrasekharBSFiles\oracle10gpdfs';
Even in this path 'D:\chandrasekharBSFiles\oracle10gpdfs'; i created a new file manually using right click -> new
named emp2.dat file .
Still it is giving the same message.
Why it is giving me the error message even though i created the directory.
Please give me the solution for the above said problem.
create or replace function load_data(p_table in varchar2,
p_cnames in varchar2,
p_dir in varchar2,
p_filename in varchar2,
p_delimiter in varchar2 default '|')
return number is
l_input utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_buffer varchar2(4000);
l_lastLine varchar2(4000);
l_status integer;
l_colCnt number default 0;
l_cnt number default 0;
l_sep char(1) default NULL;
l_errmsg varchar2(4000);
begin
l_input := utl_file.fopen(p_dir, p_filename, 'r');
l_buffer := 'insert into ' || p_table || ' values ( ';
l_colCnt := length(p_cnames) - length(replace(p_cnames, ',', '')) + 1;
for i in 1 .. l_colCnt loop
l_buffer := l_buffer || l_sep || ':b' || i;
l_sep := ',';
end loop;
l_buffer := l_buffer || ')';
dbms_sql.parse(l_theCursor, l_buffer, dbms_sql.native);
loop
begin
utl_file.get_line(l_input, l_lastLine);
exception
when NO_DATA_FOUND then
exit;
end;
l_buffer := l_lastLine || p_delimiter;
for i in 1 .. l_colCnt loop
dbms_sql.bind_variable(l_theCursor,
':b' || i,
substr(l_buffer,
1,
instr(l_buffer, p_delimiter) - 1));
l_buffer := substr(l_buffer, instr(l_buffer, p_delimiter) + 1);
end loop;
begin
l_status := dbms_sql.execute(l_theCursor);
l_cnt := l_cnt + 1;
exception
when others then
l_errmsg := sqlerrm;
insert into badlog (errm, data) values (l_errmsg, l_lastLine);
end;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose(l_input);
commit;
return l_cnt;
end load_data;
Sincerely,
Chandrasekhar B.S.