zOs/REXX/ELARIW
$@fam()
sta = 0
$=cx=0
$=ssid=DVBP
$=f1=EN1ENTERTAG
$=hasEnterTag= 0
call sqlConnect $ssid
actTb = ''
$;
$<A540769.WK.REXX(ELARIddl)
$@for li $@[
if sta=0 then do
if word($li, 1) \== create then
iterate
ix = wordPos(index, $li)
ix = word($li, ix+1)
if left(ix, 4) \== 'BUA.' then
call err 'bad ix' ix
ix = substr(ix, 5)
fx = m.i2f.ix
$=cx=- $cx+1
$=jx=- fx || right($cx, 2, 0)
$=ix=- ix
$@checkIx()
$=fx=- fx
$=fa=- m.family.fx
sta = 1
$=big = 0
$=creLine = $li
say $jx $ix 'fam' $fx $fa
iterate
end
li = $li
w1 = translate(word(li, 1))
if sta == 1 then do
if w1 \= 'ON' then
call err 'on expected' li
sta = 2
$=tb=- word(li, 2)
if \ abbrev($tb, 'BUA.') then
call err 'bad on': li
$@checkSz()
if actTb \= $tb then do
actTb = $tb
if $cx > 1 then do
$@jcl2()
call pipeEnd
end
$=job=YELAR$jx
call pipeBeLa '>' s2o('A540769.TMP.JCL('$job')')
m.tbix.0 = 0
$@jcl1()
end
call mAdd tbix, $ix
$@ixBeg()
end
else do
if w1 = 'DEFER' then do
li = ' DEFER YES'
end
else if w1 = 'PIECESIZE' then do
li = ' PARTITIONED;'
sta = 0
end
else if w1 = 'BUFFERPOOL' then do
if $big then
li = ' bufferpool BP16K2'
end
else if 0 & pos($f1, translate(li)) > 0 ,
& \ $hasEnterTag then do
lu = translate(li)
cx = pos($f1, lu)
le = strip(left(lu, cx-1))
n = space(substr(lu, cx), 1)
if n = $f1 'ASC,' | n = $f1 'ASC ,' then
li = le
else if (n = $f1 'ASC)' | n = $f1 'ASC )') ,
& right(le, 1) == ',' then do
say le length(le)
li = left(le, length(le)-1) ')'
end
else
call err 'bad' $f1':' li
end
end
$$- li
$]
if $cx > 1 then do
$@jcl2()
call pipeEnd
end
$;
$@proc jcl1 $@=[
//$job JOB (CP00,KE50),
// MSGCLASS=T,TIME=1440,
// NOTIFY=A540769
//*MAIN CLASS=LOG
//* index $ix family $fa
//DDL EXEC PGM=IKJEFT01,DYNAMNBR=200,TIME=99
//SYSTSIN DD *
DSN SYSTEM($ssid)
RUN PROGRAM(DSNTEP2) PARMS('ALIGN(LHS)') PLAN(DSNTEP2)
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//***PRINT DD DISP=SHR,DSN=A540769.WK.TEXW(PDBGENNJ)
//SYSUDUMP DD SYSOUT=*
//SYSTERM DD DUMMY
//SYSIN DD * DISP=SHR,DSN=A540769.WK.SQL(PDBGENNJ)
set current sqlid = 'S100447';
$]
$@proc ixBeg $@[
if $ixExists then $@=[
drop index bua.$ix;
commit;
$]
$$ $creLine
$]
$@proc jcl2 $@=[
commit;
// IF RC <= 4 THEN
//REBUI EXEC PGM=DSNUTILB,TIME=1440,
// PARM=($ssid,'$job.REBUI'),
// REGION=0M
//DSSPRINT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//SYSTEMPL DD DISP=SHR,DSN=$ssid.DBAA.LISTDEF(TEMPL)
//SYSIN DD *
LISTDEF IX
$@do yy=1 to m.tbIx.0 $@=[
INCLUDE INDEX BUA.$-{m.tbIx.yy} PARTLEVEL
$]
REBUILD INDEX LIST IX
SORTDEVT SYSDA
SORTNUM 140
WORKDDN(TSYUTD)
LISTDEF TS INCLUDE TABLESPACES LIST IX
RUNSTATS TABLESPACE LIST TS
INDEX(ALL) KEYCARD UPDATE ALL
// ENDIF
//*** jclEnd $-{m.tbIx.0} ix $-{m.tbIx.1} ...
$]
$@proc fam $@[
$<A540769.WK.REXX(ELARIx)
oldFa = ''
m.family.0 = 0
$@for li $@[
parse value $li with fa ix .
if ix \== '' then do
call mAdd family, fa
m.i2f.ix = m.family.0
end
else do
m.i2f.fa = m.family.0
end
$]
$]
$@proc checkSz $@[
parse value $tb with cr'.'tb
et = sqlPreAllCl(1, "select 1",
"from sysibm.sysColumns",
"where tbCreator = '"cr"' and tbName ='"tb"'" ,
"and name = 'EN1ENTERTAG'", s , ":c1")
$=hasEnterTag=- et
say "hasEnterTag" $hasEnterTag $tb
call sqlPreAllCl 1, "select count(*),max(s.dbName), max(s.name), ",
"real(max(r.space)) * 1024" ,
"from sysibm.systables t, sysibm.sysTableSpace s,",
"sysibm.systableSpaceStats r" ,
"where t.creator = '"cr"' and t.name ='"tb"'" ,
"and t.dbName = s.dbName and t.tsName = s.name",
"and r.dbId = s.dbId and r.psId = s.psId",
, s, ":cnt, :qDb :i1, :qTs :i2, :qSz :i2"
if cnt >= 1 then do
$=big =- qSz > 5e9
say cr'.'tb m.s.0 '=>' qDb'.'qTs '=' qSz 'big' $big
end
else do
say "||| no table" cr"."tb "for ix" $ix
$=big=0
end
$]
$@proc checkIx $@[
ixTy = 'noIndex'
cnt =sqlPreAllCl(1, "select indexType",
"from sysibm.sysIndexes",
"where creator = 'BUA' and name ='"$ix"'", s , ":ixTy")
say ixTy 'ix bua.'$ix 'cnt' cnt
$=ixExists =- cnt = 1
$]
$#out 20101110 16:38:03
$#out 20101110 16:37:12
$#out 20101110 16:36:01
$#out 20101110 16:32:10
$#out 20101110 16:28:40
$#out 20101110 16:25:56
$#out 20101110 16:22:21
$#out 20101110 16:06:09
$#out 20101101 13:21:42
$#out 20101110 16:03:52
$#out 20101101 13:12:12