: !/bin/sh unlfile="/u/catcom/tx/fxdh1.unl" runisql <= "01/01/2008" and hist_date <= "22/01/2009" and hist_line5[50,58] != hist_pargrp order by hist_date, hist_time SQLCMD0 #VAC|CCM|16/10/2008|10:37:04|DENNIS|1|m| # |VAC|21/10/2008|11:24:06|SHIRLEYD|1|m| awk -F'|' ' function clip(s) { sub(/[ \t]*$/,"",s) return s } { f = 0 a_pargrp = clip($(++f)) b_pargrp = clip($(++f)) hist_date = clip($(++f)) hist_time = clip($(++f)) hist_name = clip($(++f)) hist_updno = clip($(++f)) hist_updop = clip($(++f)) if ( a_pargrp == "" ) a_pargrp = b_pargrp printf("-- %s,%s,%s,%s,%s,%s,%s\n", a_pargrp, b_pargrp, hist_date, hist_time, hist_name, hist_updno, hist_updop) sql1 = sql1 " hist_line0, hist_line1, hist_line2, hist_line3, hist_line4, hist_line5" sql1 = "" sql1 = sql1 "update dirhist" sql1 = sql1 " set hist_pargrp = \"" a_pargrp "\"" sql1 = sql1 " ,hist_line1[15,22] = \"" a_pargrp "\"" sql1 = sql1 " ,hist_line5[50,58] = \"" a_pargrp "\"" sql1 = sql1 " where hist_date = \"" hist_date "\"" sql1 = sql1 " and hist_time = \"" hist_time "\"" sql1 = sql1 " and hist_updop = \"c\"" sql1 = sql1 " and hist_name = \"" hist_name "\"" sql1 = sql1 " and hist_updno = " hist_updno ";" sql2 = "" sql2 = sql2 "update dirhist" sql2 = sql2 " set hist_pargrp = \"" b_pargrp "\"" sql2 = sql2 " ,hist_line1[15,22] = \"" b_pargrp "\"" sql2 = sql2 " ,hist_line5[50,58] = \"" b_pargrp "\"" sql2 = sql2 " where hist_date = \"" hist_date "\"" sql2 = sql2 " and hist_time = \"" hist_time "\"" sql2 = sql2 " and hist_updop = \"m\"" sql2 = sql2 " and hist_name = \"" hist_name "\"" sql2 = sql2 " and hist_updno = " hist_updno ";" print sql1 print sql2 } ' <"$unlfile" | runisql | tee fxdh1.out