hi all,
We are checking for the delimited file records validation
Delimited file will have data like this:
Aaaa|sdfhxfgh|sdgjhxfgjh|sdgjsdg|sgdjsg|
Aaaa|sdfhxfgh|sdgjhxfgjh|sdgjsdg|sgdjsg|
Aaaa|sdfhxfgh|sdgjhxfgjh|sdgjsdg|sgdjsg|
Aaaa|sdfhxfgh|sdgjhxfgjh|sdgjsdg|sgdjsg|
So we are checking for where the records of files we got is having validating length or not.
The structer of file/table will be configured in Teradata, we will fetch the column length from tht file.
ex:
col1 varchar(5),
col2varchar(5),
col3varchar(5),
col4 varchar(5)
we hav to check all columns have field length not greater than 5 if its then we will write the hole error record to bad file.
In the script col_nm col_order_num col_len
col_nm =column name
col_order_num =oder number will be order of column in tht table�.it will be 1 2 3�.like tht
col_len=length of the column
#------------------------------------------
# Reading through the file and checking for the column length
#----------------------------------------------------
logNote "Reading through the temp file and and checking for the column length"
while read col_nm col_order_num col_len
do
typeset -i col_len
typeset -i col_len_good
col_len_good=`expr $col_len + 1`
logNote "col_nm : $col_nm"
logNote "col_order_num : $col_order_num"
logNote "col_len : $col_len"
logNote "col_len_good : $col_len_good"
awk 'BEGIN{col_ord='$col_order_num';col_l='$col_len'}{FS="|"}{if (length($col_ord) > col_l) print $0;}' $Src_File >> $Src_File.bad
awk 'BEGIN{col_ord='$col_order_num';col_l='$col_len_good'}{FS="|"}{if (length($col_ord) < col_l) print $0;}' $Src_File > $Src_File.temp
rm -f $Src_File
mv $Src_File.temp $Src_File
done <$RPT_FILE
================================
we are using this script but its very slow in validating, preformance is very slow
can amy ione come up with soem better way plzs.