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

  1. /* rexx */
  2. /*
  3. Set error traps
  4. */
  5. signal on error
  6. signal on syntax  name error
  7. signal on halt    name error
  8. signal on failure name error
  9.  
  10. /*
  11. General initialization
  12. */
  13. '@echo off'
  14. flinit = 0 /* flag, 1=initialization has been completed */
  15.  
  16. /*
  17. Main loop
  18. */
  19. do forever
  20.    'cls'
  21.    say
  22.    say 'G2Cols --- Testing program for REXXGDB2.DLL function: G2SelectCols'
  23.    say 'Simon Husin (husin@ibm.net)'
  24.    say 'Kent, Washington, U.S.A., December 1995'
  25.    say
  26.    say 'Run test number:'
  27.    say '1   All columns of a table (ORG)'
  28.    say '2   Count(*) on table (ORG)'
  29.    say '3   Constant, named and numbered columns of a table (ORG)'
  30.    say
  31.    say 'Any other to Quit'
  32.    say
  33.    say 'Enter your selection and/or press Enter'
  34.    pull choice
  35.    if wordpos(choice, '1 2 3') = 0 then leave
  36.  
  37.    if \flinit then do
  38.       if rxfuncquery('g2LoadFuncs') then do
  39.          say
  40.          say 'Loading REXXGDB2 Functions...'
  41.          call rxfuncadd 'g2LoadFuncs', 'REXXGDB2', 'g2LoadFuncs'
  42.          say 'Result =' g2LoadFuncs()
  43.          end
  44.       say
  45.       say 'Connecting to SAMPLE database...'
  46.       call time 'R'
  47.       call g2connectshare 'SAMPLE'
  48.       say 'Completed in (seconds)' time('E')
  49.       flinit = 1
  50.       end
  51.  
  52.    select
  53.      when choice = 1 then call Test1
  54.      when choice = 2 then call Test2
  55.      otherwise            call Test3
  56.      end
  57.    say
  58.    say 'Press Enter to continue...'
  59.    pull choice
  60.    end
  61.  
  62. /*
  63. Release all locks with Commit
  64. */
  65. if flinit then do
  66.    say
  67.    say 'Commiting...'
  68.    call g2commit
  69.    call time 'R'
  70.    say 'Completed in (seconds)' time('E')
  71.    end
  72. return 0
  73.  
  74. Test1:
  75. say center(' TEST1 ', 79, '-')
  76. sql = 'select * from org'
  77. say 'SQL:' sql
  78. say 'Executing G2SelectCols(SQL, COLS.)...'
  79. call time 'R'
  80. retcode = g2selectcols(sql, cols.)
  81. elapse = time('E')
  82. say 'Return Code           ' retcode
  83. say 'Completed in (seconds)' elapse
  84. say
  85. say 'Stem tot# elements    ' cols.0
  86. if retcode = 0 | retcode = 100 then do
  87.    do i = 1 to cols.0
  88.       say 'Element COLS.'i '=' cols.i
  89.       end
  90.    end
  91. return
  92.  
  93. Test2:
  94. say center(' TEST2 ', 79, '-')
  95. sql = 'select count(*) from org'
  96. say 'SQL:' sql
  97. say 'Executing G2SelectCols(SQL, COLS.)...'
  98. call time 'R'
  99. retcode = g2selectcols(sql, cols.)
  100. elapse = time('E')
  101. say 'Return Code           ' retcode
  102. say 'Completed in (seconds)' elapse
  103. say
  104. say 'Stem tot# elements    ' cols.0
  105. if retcode = 0 | retcode = 100 then do
  106.    do i = 1 to cols.0
  107.       say 'Element COLS.'i '=' cols.i
  108.       end
  109.    end
  110. return
  111.  
  112. Test3:
  113. say center(' TEST3 ', 79, '-')
  114. sql = "select 'Test', deptnumb, count(*) from org group by deptnumb"
  115. say 'SQL:' sql
  116. say 'Executing G2SelectCols(SQL, COLS.)...'
  117. call time 'R'
  118. retcode = g2selectcols(sql, cols.)
  119. elapse = time('E')
  120. say 'Return Code           ' retcode
  121. say 'Completed in (seconds)' elapse
  122. say
  123. say 'Stem tot# elements    ' cols.0
  124. if retcode = 0 | retcode = 100 then do
  125.    do i = 1 to cols.0
  126.       say 'Element COLS.'i '=' cols.i
  127.       end
  128.    end
  129. return 0
  130.  
  131.  
  132.  
  133. error:
  134. say 'Error detected...'
  135. return 10
  136.  
  137. syntax:
  138. say 'Syntax error detected...'
  139. return 20
  140.