Etl Flowchart
Etl Flowchart
cl_no = Client number pr_no = Period number ld_txt = Load text txt_ld = Text load tran_mod = Transformation module str = String msg = Log messages
if cl_no != 1
if cl_no is null
Print error
If ld_txt = 1
P2
If txt_ld != 0
If tran_mod is null
P3
If error != 0
P2 Variables c_id = client id row_cnt = row count msg = message str = string sql_tab = Sql table fmt_fil = Format file tem_fil = Template file txt_fil = text file other_txt_fil = other text file txt_loc = Text location txt_fullpth = Text full path fmt_loc = Format file location
if cl_no != 1
Declare vars c_id, row_cnt, error, sql_cmd msg, str,sql_tab, fmt_fil, tem_fil, txt_fil, other_txt_fil, txt_loc, txt_fil_fullpth, fmt_loc
error = 0
If pdt = Null || pdt not in(lps,heloc Heload) || cl_no = null || p_no = null
pdt = lower(pdt)
sql_tab = case when lower(pdt) = lps then raw_c_id_pno_lps when lower(pdt) = heloc then raw_cid_pno_heloc when lower(pdt) = heloan then raw_cid_pno_heloan
txt_fil = case when lower(pdt) = lps then raw_c_id_pno_lps.txt when lower(pdt) = heloc then raw_cid_pno_heloc.txt when lower(pdt) = heloan then raw_cid_pno_heloan.txt
txt_loc = sel txt_fil from tab_fil_loc fmt_loc = sel fmt_fil from tab_fil_loc
call proc sp_logit(Begin: text import) call proc sp_logit(Text file location) call proc sp_logit(Format file) call proc sp_logit(Template file)
Declare vars filename, input_txt cursor for (select filename from input_txt)
While fetch_status = 0
If cl_no in (60,183)
If cl_no = 48
sql_cmd = Bulk insert rawdata + sql_tab from txt_loc + filename with format file..
sql_cmd = Bulk insert rawdata + sql_tab from txt_loc + filename with format file..
Print(sql_cmd)
exec (sql_cmd)
If error = 0
call proc sp_logit(error loading from + txt_loc + filename) call proc sp_logit(cast error + error)
call proc sp_logit(sel no of rows from sysindexes) call proc sp_logit(End: text import + c_id + pdt)
return
P3
If cl_id <> 1
Parent_id =37 C_id=select c_id from clients Rawdata =rawdata.dbo+c_id+p_no+_lps Trans_table =trans_+c_id+p_no+_lps
If c_id =NWB
Msg=PRU& WFH raw data must exists When processing this client
If NWB_rows=0
Msg= rawdata+NWB_rawdata+:+NWB_rows+Rows
Msg=selection criteria:ltrim(rtrim(branch_cd))
Sqlstr=trans_sp_rename+trans_tab
Exe sqlstr
Create table #dupes Inserting values into #dupes Dupcount=select count(*) dupes Msg=duplicate rows found in rawdata+dupcount
Sql_cmd=c_id=cast(c_id as varchar)+ p_id=cast(p_id as varchar)+ p_no=cast (p_no as varchar)+ Select add_per=cast (add_per as varchar)+, C_id=cast (c_id as varchar)+, . . . . . Into Trans.dbo+@Trans_tab from rawdata + R
Exec sql_cmd
If err!=0
Msg=trans_tab+trans_tab
return