zOs/SQL/PLANQUER

$#@
call sqlConnect dbtf
call sqlPrepare 1,
   ,'select explain_time, queryNo, type, query_Stage, seqNo,',
             'length(node_data), node_data',
        'from A540769.dsn_query_table'    ,
        'order by explain_time, queryNo, type, query_Stage, seqNo'
  /*    "where queryno = 110" ,
           "and explain_time ='2010-03-15-16.03.26.767284'" */
call sqlOpen 1
$=o1 = $''
do cn=1 while sqlFetchInto(1, ':et, :qNo, :ty, :qs, :sq, :le, :no')
    $@grChg-{et qNo, ty qs ,sq}
$*( $$- cn ml 'le' le if(le=length(no), '=', '<>') $*+
            'length' length(no)':'left(no,50)
    $$- '  1='substr(no, 1, 70)
    $$- ' 51='substr(no, 51, 70)
    $$- '101='substr(no,101, 70)
    $$- '151='substr(no,151, 70)
    $$- '201='substr(no,201, 70)
    $$- '251='substr(no,251, 70)
$*) cx = 0
    wm = 60
    do while cx < length(no)
        we = min(cx+wm, length(no))
        w2 = lastPos('<', no, we)
        if w2 > cx+10 then
            w2 = w2 - 1
        else
            w2 = we
        $$- ' ' substr(no, cx+1, w2-cx)
        cx = w2
        end
    end
    $@grChg{}
call sqlDisconnect
$@proc grChg $@[
parse arg , et qNo, ty qs, sq
    say 'grpChg et qNo' $o1 '=>' et qNo ty qs 'seq' sq
    if $o1 \== '' then $@[
        if $o1 \== et qNo | $o2 \== ty qs then
            $$- ' </qGr2>'
        if $o1 \== et qNo then
            $$- '</qGr1>'
        if et == '' then
            $$- "</qGr>"
        $]
    if et \== '' then $@[
        if sq \== 1 then
            call err 'implement sq' sq
        if $o1 \== et qNo then $@[
            if $o1 == '' then
                $$- "<qGr>"
            $$- "<qGr1 et='"et"' qno='"qNo"'>"
            $=o1 =- et qNo
            $=o2 =- ''
            $]
        if $o2 \== ty qs then $@[
            $$- " <qGr2 ty='"ty"' qs='"qs"'>"
            $=o2 =- ty qs
            $]
        $]
$]
$#out                                              20110514 00:09:55
<qGr>
<qGr1 et='2011-05-13-22.13.44.390000' qno='300'>
 <qGr2 ty='SELECT' qs='  AFTER   '>
  <QUERY><SUBQUERY QBNO='1' PRUNED='N'>(<SEL-CLAUSE>SELECT
  <SEL-LIST STAR='N'><LIST-ITEM TYPE='COLM'>