Search This Blog

Thursday, March 18, 2010

Loading an empty table using fastload with data present in multiple files

This will show how to load an empty table using fastload with data present in multiple files.
let us do this with 3 files.each file contains 2 records each.

A the table contains one column and that is integer for simplicity.

data file : f1-2.dat contains values 1 and 2.
f3-4.dat contains values 3 and 4.
f5-6.dat contains values 5 and 6.

lets prepare 3 fastload scripts.

STEP1:

fload1.fl :-
.logon abc/xyz,xyz
drop table errtbl1;
drop table errtbl2;
drop table test1;
create table test1(col1 integer);

.BEGIN LOADING test1 ERRORFILES errtbl1,errtbl2;
DEFINE col1(integer)
FILE=f1-2.dat;
INSERT INTO test1 values(:col1);
.logoff

fload2.fl :-
.logon abc/xyz,xyz
.BEGIN LOADING test1 ERRORFILES errtbl1,errtbl2;
DEFINE col1(integer)
FILE=f3-4.dat;
INSERT INTO test1 values(:col1);
.logoff


fload3.fl :-
.logon abc/xyz,xyz
.BEGIN LOADING test1 ERRORFILES errtbl1,errtbl2;
DEFINE col1(integer)
FILE=f5-6.dat;
INSERT INTO test1 values(:col1);
.END LOADING
.logoff.

STEP 2:
execute the 3 fastload scripts in sequence like
first execute fload1.fl
next fload2.fl
next fload3.fl


after executing fload3.fl the table test1 will be loaded with 6 records.

Explanation :
After the execution of fload1.fl and fload2.fl fastload is in paused state.
when the fload3.fl is executed (i.e) when the fastload sees .END LOADING statement it will update the error tables and target table and release locks.
makesure that each .BEGIN LOADING.. statement should have the same error tables specified.



1 comment: