home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxgdb2.zip / G2Data.CMD < prev    next >
OS/2 REXX Batch file  |  1997-08-10  |  2KB  |  101 lines

  1. /* rexx */
  2. parse arg argument
  3.  
  4. signal on error
  5. signal on syntax  name error
  6. signal on halt    name error
  7. signal on failure name error
  8. '@echo off'
  9.  
  10. reqrows = 1
  11. sql     = strip(argument)
  12.  
  13. if arg() > 0 then do
  14.    if datatype(word(argument, 1)) = 'NUM' |,
  15.       translate(word(argument, 1)) \= 'SELECT' then do
  16.       reqrows = word(argument, 1)
  17.       sql     = strip(subword(argument, 2))
  18.       end
  19.    end
  20.  
  21. if left(sql, 1) = '"' then
  22.    sql = strip(substr(sql, 2, length(sql) - 2))
  23.  
  24. sql = strip(sql)
  25. if sql = '' then
  26.    sql = 'select * from staff where id = 80'
  27.  
  28. 'cls'
  29. say
  30. say 'G2Data --- Testing REXXGDB2.DLL function: G2SelectData'
  31. say 'Simon Husin (husin@ibm.net)'
  32. say 'Kent, Washington, U.S.A., December 1995'
  33. say
  34. say 'SQL:' sql
  35. say 'MAX:' reqrows
  36.  
  37. say
  38.  
  39. if rxfuncquery('g2LoadFuncs') then do
  40.    say
  41.    say 'Loading REXXGDB2 Functions...'
  42.    call rxfuncadd 'g2LoadFuncs', 'REXXGDB2', 'g2LoadFuncs'
  43.    say 'Result =' g2LoadFuncs()
  44.    end
  45.  
  46. say
  47. call time 'R'
  48. say 'Connecting        ' g2connectshare('SAMPLE') time('R')
  49.  
  50. say
  51. call time 'R'
  52. retcode = g2selectdata(sql, data., reqrows)
  53. say 'Selecting data    ' retcode time(R)
  54.  
  55. say 'DATA.0   =' data.0
  56. say 'DATA.0.0 =' data.0.0
  57. if retcode = 0 | retcode = 100 then
  58. do r = 1 to data.0
  59.    do c = 1 to data.0.0
  60.       say 'DATA.'r'.'c '=' data.r.c '    length='length(data.r.c)
  61.       end
  62.    end
  63.  
  64. say
  65. say 'DB2/2 database NULL character(s) were found in the selected data.'
  66. say "Type a character to replace the NULL character (in REXX = '')"
  67. parse pull nullchar .
  68.  
  69. say
  70. call time 'R'
  71. retcode = g2selectdata(sql, 'DATA.', , nullchar)
  72. say 'Selecting data    ' retcode time('R')
  73.  
  74. say 'DATA.0   =' data.0
  75. say 'DATA.0.0 =' data.0.0
  76. if retcode = 0 | retcode = 100 then
  77. do r = 1 to data.0
  78.    do c = 1 to data.0.0
  79.       say 'DATA.'r'.'c '=' data.r.c '    length='length(data.r.c)
  80.       end
  81.    end
  82.  
  83. say
  84. call time 'R'
  85. say 'Commiting         ' g2commit() time('R')
  86. say 'Before dropping [data.]...'
  87. call syssleep 10
  88. drop data.
  89. say 'After dropping [data.]...'
  90. return 0
  91.  
  92.  
  93.  
  94. error:
  95. say 'Error detected...'
  96. return 10
  97.  
  98. syntax:
  99. say 'Syntax error detected...'
  100. return 20
  101.