zOs/SQL/TXBI014

$#@
$= fun = s               $** s = show
                         $** a = alter restart to mx+1
$= tb = TXBI014
$= cr = BUA
$= idCol = ATTRID
call sqlConnect DEVG
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                                              20141204 10:37:19
$#out                                              20141204 10:36:43
$#out                                              20141204 10:34:11
$#out                                              20141204 10:34:04
$#out                                              20141204 10:33:57
$#out                                              20141204 10:32:07
$#out                                              20141204 10:31:58
$#out                                              20141204 10:31:28
$#out                                              20141204 10:31:06