zOs/SQL/WI104

$*( generate sql to update twi104h1
       however, the olap expression does need to much sort space ....
$*)

say time() 'start'
call sqlConnect Dbof
m.sql_retOk = m.sql_retOk 'rb'
$= fx = 0
$= ux = 0
$= cx = 0

$@comPre
say time() 'query'
call sqlQuery 57,
  , "select WI10400T, WI10400D, WI10400L, Wi104PK, RID(T) rid" ,
        "from oa1p.TWI104H1004 T"                    ,
        "order by WI10400T, WI10400D, WI10400L"    ,
        "optimize for 1000 rows"
say time() 'do'
$do fx=1 to 1e5 while sqlFetch(57, ff) $@[
$*( say $fx m.ff.WI10400T m.ff.WI10400D m.ff.WI10400L m.ff.Wi104PK,
          m.ff.rid $*)
    if m.ff.wi104pk = 0 then do
        call sqlUpdateExecute 58, m.ff.rid
        if m.sql.58.updateCount = 1 then
            $=ux =- $ux + 1
        else
            call err 'updateCount=' m.sql.58.updateCount
        if $ux // 100 = 0 then
            $@comPre
        end
    else do
        cv = SUBSTR(m.ff.WI10400L,5,1)SUBSTR(m.ff.WI10400L,4,1)
        if cv < 10 then
            cv = '1'cv
        if cv <> m.ff.Wi104PK then
            say '???mismatch' $fx m.ff.WI10400T m.ff.WI10400D ,
                    m.ff.WI10400L m.ff.Wi104PK 'should be' cv
        end
    if $fx // 1000 = 0 then
        $@sayCount
    $]
$@comPre
$@sayCount

$proc $@/comPre/
    $** say $fx $cx 'commit'
    call sqlCommit
    $= cx =- $cx + 1
call sqlUpdatePrepare 58, "update oa1p.TWI104H1004 t set wi104pk =",
            "CAST(CASE WHEN SUBSTR(WI10400L,5,1)='0' THEN '1'",
                       "ELSE '0'END" ,
                  "|| SUBSTR(WI10400L,5,1)" ,
                  "|| SUBSTR(WI10400L,4,1) AS SMALLINT)",
            "where rid(t) = ?"
$/comPre/

$proc $@/sayCount/
    say time() 'read' $fx', updated' $ux', commits' $cx', key' ,
          m.ff.WI10400T m.ff.WI10400D m.ff.WI10400L
$/sayCount/
$#out                                              20161230 07:35:48