Search This Blog

Monday, February 13, 2012

Options in ODI KM's/Procedures

Loading of File: End of line is not specified

Purpose of options in ODI: Options plays a vital role & though this conditional ( just like if,cases in sql) based queries/codes can be generated for loading purposes.

I have a scenario where my source is a File  ( fixed file -position based records) & its EOL( end of line) is not specified). All the records are appearing in the same line.
The length of record is 8 so below text contain two records
ABCD1234QRST5421

Layout or record C1(1:2),C2(3:4),C3(5:8)
record1: ABCD1234
record2: QRST5421

create datastore for file ABC



Now I want to load the records using LKM file to Oracle(sqlldr).

Step1: First Add an option (FIXED_REC_LENGTH) in LKM which will hold length of record.
Step2: Go to "Generate CTL file" command in LKM & change the code.
If
 Fixed record length option is not null  then it will generate control file with fixed record length
else
It will perform generate normal ODI control file code.


Apply the changes in control file & save it.

Now Create a interface for load file to oracle & in the flow diagram set option "FIXED_REC_LENGTH"
as 8



Choose appropriate IKM ( sql control append) & execute the interface.

CTL generated through LKM is


SnpsOutFile "-File=C:/SNAPON/ABC.ctl"

OPTIONS (
SKIP=0,
ERRORS=0,
DIRECT=FALSE
)
LOAD DATA
INFILE "C:/SNAPON/EOL.txt"  "FIX 8"
BADFILE "C:/SNAPON/ABC.bad"
DISCARDFILE "C:/SNAPON/ABC.dsc"
DISCARDMAX 1
INTO TABLE SNAPON_W.C$_0ABC
(
C2_C1 POSITION(1:2),
C1_C2 POSITION(3:4),
C3_C3 POSITION(5:8)
)


Check target table & 2 records inserted through load.



In next post will we discuss "Variabale" based "Options".



No comments:

Post a Comment