zOs/SQL/ALTERGEN
$#@
$*( alter genid to restart at next value
$*)
$= fun = s $** s = show
$** a = alter restart to mx+1
$= tb = TTT609A1
$= cr = OA1P
$= idCol = "INSTANCE_TUID"
call sqlConnect DE0G
mxC = sql2One('select max('$idCol') from' $cr'.'$tb)
say $cr'.'$tb 'max' $idCol '=' mxC
mxS = sql2One('select value(s.restartWith, s.maxAssignedVal)' ,
'from sysibm.sysSequencesDep d' ,
'join sysibm.sysSequences s' ,
'on s.sequenceId = d.bSequenceId' ,
"where dName = '"$tb"' and dCreator = '"$cr"'")
say $cr'.'$tb 'sequece max =' mxS
if $fun == 'a' then $@[
call sqlUpdate 3, 'alter table' $cr'.'$tb,
'alter' $idCol 'restart with' (mxC + 1)
say 'altered to restart with' (mxC + 1)
$]
$#out 20141212 11:35:05