Wsh Tutorial: SQL

  • syntax: -
  • beispiel: {RZ4+dsn.beispiel.wsh(wshTut39)}

There is a direct interface into dsnRexx, using sqlQuery, sqlFetsch, sqlUpdate etc. Sql Output can be transformed to objects, prepare and open/execute with parameters is supported, etc.

The more powerfull interface, allowing executing sqls on different sysPlexes (with csmASQL or by executing WSH in a remote tso session). Here we use sqlRdr() or sqlStmts. The later contains a full sqlScanner, supporting multiple statements, spufi Comments, etc..

$#@
$$ --- sql ---
call sqlConnect 'rzz/de0g'
$= nL = 'SYSPACK%'
$= r3 = 'AGE' ,'DEP', 'TMT'
$<>
$<=¢
    selekt creator cr, name tb, type
        from sysibm.sysTables
        where creator = 'SYSIBM' and name like $nL
             and right(strip(name), 3) in ($r3)
    ;
    selekt current timestamp now, current server from sysibm.sysDummy1
$!
call sqlStmts
$<>
$<=¢
    selekt creator cr, name tb
        from sysibm.sysTables
        where creator = 'SYSIBM' and name like 'SYSPACK%'
             and type = 'T'
             and right(strip(name), 3) in ('AGE' ,'DEP', 'TMT')
$!
$@. sqlRdr()
$|
$=p =- '         '
$forWith $@=¢
$p selekt count(*), '$TB' table from $CR.$TB
$=p =- 'union all'
$!
$| call sqlStmts
$#out                                              20161127 12:35:55
--- sql ---
CR     TB               T
SYSIBM SYSPACKAGE       T
SYSIBM SYSPACKDEP       T
SYSIBM SYSPACKSTMT      T
SYSIBM SYSPACKSTMT_STMT X
4 rows fetched: selekt creator cr, name tb, type from sysibm.sysTables whe...
NOW                        COL2
2016-11-27-12.35.56.589742 CHROI00ZDE0G
1 rows fetched: selekt current timestamp now, current server from sysibm.s...
   COL1 TABLE
 266692 SYSPACKAGE
5921451 SYSPACKDEP
6450368 SYSPACKSTMT
3 rows fetched: selekt count(*), 'SYSPACKAGE' table from SYSIBM .SYSPACKAG...
$#out                                              20161127 12:34:38

$

character set problems

wikiz/osname
¢![]square brackets
|!exclamation mark