zOs/SQL/CATCOPWX

call errReset 'h'
$=subsys = DBOF
$=creator = A540769
$=creator = sysibm
$=curr = '2008-03-13-11.11.11'
$=last = '2008-03-05-11.11.11'
$=mgmtClas = A000Yneu
call sqlConnect $subsys
$=out  £ catDsn("~catCopy.out2 ::F")
call jOpen $out, 'w'
$£  timing() 'be' $subsys $creator $curr $last
say timing() 'be' $subsys $creator $curr $last
$;
$<<[eof
select
    c.dbname, c.tsName, c.dsNum, c.icType, c.dsName, c.timestamp,
              c.copyPagesf * 1024 * s.pgSize copied,
    case when c.icType <> 'F'     then 'IN'
         when c.timestamp = x.new then 'NW'
         when c.timestamp = x.last then 'LA'
         else 'FU' end myType
    from
(
select dbName, tsName, dsNum, max(timestamp) new,
        max(case when timestamp <=   $last
                 then timestamp else '1900-01-01-00.00.00'  end) last
    from $creator.sysCopy
    where icType = 'F' $** and dbName = 'MF01A1P'
                       and timestamp <= $curr
    group by dbName, tsName, dsNum
) x ,
    $creator.sysCopy c,
    sysibm.sysTablespace s
    where c.icType in ('F', 'I')
        and c.dbName = x.dbName
        and c.tsName = x.tsName
        and c.dsNum  = x.dsNum
        and c.timestamp <  x.new
        and c.timestamp >= x.last
        and s.dbName = x.dbName
        and s.name = x.tsName
$** order by c.dbName, c.tsName, c.dsNum, c.timestamp desc
    with ur
eof call sql 1 $! pref = '' $@{
    lst = ''
    cDb = 0
    cTs = 0
    cPa = 0
    cCo = 0
    c.nw.c = 0
    c.nw.b = 0
    c.la.c = 0
    c.la.b = 0
    c.fu.c = 0
    c.fu.b = 0
    c.in.c = 0
    c.in.b = 0
    $@for c $@{
        if cCo // 10000 = 0 then do
            say timing() cDb 'dbs,' cTs 'TS,' cPa 'parts,' cCo 'copies'
            $£  timing() cDb 'dbs,' cTs 'TS,' cPa 'parts,' cCo 'copies'
            if cCo >=200000 then leave
            end
        dsn = ${c.DSNAME}
        crn = ${c.DBNAME}'.'${c.TSNAME}'.'${c.DSNUM}
        if crn <> lst then do
            if ^ abbrev(lst, ${c.DBNAME}'.') then do
                cDb = cDb + 1
                end
            if ^ abbrev(lst, ${c.DBNAME}'.'${c.TSNAME}'.') then
                cTs = cTs + 1
            cPa = cPa + 1
            sta = 'NW'
            lst = crn
            end
        tp = ${c.MYTYPE}
        if tp ^== 'NW' then
            call jWrite $out,'ALTER' ${c.DSNAME} 'MGMTCLAS('$mgmtClas')'
        cCo = cCo + 1
        c.tp.c = c.tp.c + 1
        c.tp.b = c.tp.b + ${c.COPIED}
        $}
    $£ cDb 'dbs,' cTs 'TS,' cPa 'parts,' cCo 'copies'
    $£ 'neu ' right(c.nw.c, 10) c.nw.b
    $£ 'last' right(c.la.c, 10) c.la.b
    $£ 'full' right(c.fu.c, 10) c.fu.b
    $£ 'inc ' right(c.in.c, 10) c.in.b
$} $;
$£  timing() 'end' $subsys $creator $curr $last
say timing() 'end' $subsys $creator $curr $last
call jCLose $out
call SqlDisconnect
$***out            20080313 12:03:03
12:03:03 0    658.11 be DBOF sysibm '2008-03-13-11.11.11' '2008-03-12-11.11.11'
12:11:38 0    985.50 0 dbs, 0 TS, 0 parts, 0 copies
12:11:51 0    997.17 19 dbs, 788 TS, 2229 parts, 10000 copies
12:12:04 0   1008.90 19 dbs, 800 TS, 3835 parts, 20000 copies
12:12:19 0   1020.45 3149 dbs, 4293 TS, 10874 parts, 30000 copies
12:12:33 0   1031.92 3267 dbs, 6766 TS, 17228 parts, 40000 copies
12:12:48 0   1043.42 3384 dbs, 8381 TS, 24431 parts, 50000 copies
12:13:03 0   1055.01 3530 dbs, 11515 TS, 30566 parts, 60000 copies
3571 dbs, 12065 TS, 36973 parts, 68692 copies
neu       36975 5.58642407E+12
last      11808 1.98522453E+12
full       2600 4.95282462E+11
inc       17309 2.47778851E+10
12:13:16 0   1065.06 end DBOF sysibm '2008-03-13-11.11.11' '2008-03-12-11.11.11'
$***out            20080313 11:40:19