The file may have anywhere between 1000 records (if it's a weekly load) or 50000 records (if the client wants to completely reload his list). The file format is delimited ASCII file (maybe about 30 columns per row), information about delimiter for row and columns is stored in a settings table.
thanks,
ilya
May 23, 2004 - 9:00 pm UTC
what about something like this:
create or replace directory test as '/home/tkyte'
/
drop table t;
create table t ( a number, b number, c varchar2(30), d varchar2(30), e varchar2(30), f clob);
declare
l_bfile bfile;
l_size number;
l_last number := 1;
l_current number;
l_clob clob;
l_rec t%rowtype;
l_comma raw(1) := utl_raw.cast_to_raw( ',' );
begin
l_bfile := bfilename( 'TEST', 'x.dat' );
dbms_lob.fileopen( l_bfile );
l_size := dbms_lob.getlength( l_bfile );
loop
dbms_application_info.set_client_info( l_last || ' of ' || l_size );
l_current := dbms_lob.instr( l_bfile, l_comma, l_last, 1 );
exit when (nvl(l_current,0) = 0);
l_rec.a := utl_raw.cast_to_varchar2(dbms_lob.substr( l_bfile, l_current-l_last, l_last ));
l_last := l_current+1;
l_current := dbms_lob.instr( l_bfile, l_comma, l_last, 1 );
exit when (nvl(l_current,0) = 0);
l_rec.b := utl_raw.cast_to_varchar2(dbms_lob.substr( l_bfile, l_current-l_last, l_last ));
l_last := l_current+1;
l_current := dbms_lob.instr( l_bfile, l_comma, l_last, 1 );
exit when (nvl(l_current,0) = 0);
l_rec.c := utl_raw.cast_to_varchar2(dbms_lob.substr( l_bfile, l_current-l_last, l_last ));
l_last := l_current+1;
l_current := dbms_lob.instr( l_bfile, l_comma, l_last, 1 );
exit when (nvl(l_current,0) = 0);
l_rec.d := utl_raw.cast_to_varchar2(dbms_lob.substr( l_bfile, l_current-l_last, l_last ));
l_last := l_current+1;
l_current := dbms_lob.instr( l_bfile, l_comma, l_last, 1 );
exit when (nvl(l_current,0) = 0);
l_rec.e := utl_raw.cast_to_varchar2(dbms_lob.substr( l_bfile, l_current-l_last, l_last ));
l_last := l_current+1;
insert into t (a,b,c,d,e,f) values (l_rec.a, l_rec.b, l_rec.c, l_rec.d, l_rec.e, empty_clob() )
returning f into l_rec.f;
l_current := dbms_lob.instr( l_bfile, '0A', l_last, 1 );
exit when (nvl(l_current,0) = 0);
dbms_lob.loadFromFile( l_rec.f, l_bfile, l_current-l_last+1, 1, l_last );
l_last := l_current+1;
end loop;
end;
/
to avoid the issue alltogether?