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

  1. /* rexx */
  2. '@cls'
  3. say
  4. say 'G2Funcs --- Testing program for REXXGDB2.DLL functions'
  5. say 'Simon Husin (husin@ibm.net)'
  6. say 'Kent, Washington, U.S.A., December 1995'
  7. say
  8.  
  9. line = copies('-', 79)
  10.  
  11. errmsg = ''
  12. signal on error
  13. signal on syntax  name error
  14. signal on halt    name error
  15. signal on failure name error
  16. /*
  17. ------------------------------------------------------------------------
  18.                    Creating two packages for REXXGDB2
  19. ------------------------------------------------------------------------
  20. */
  21. say line
  22. say 'If this is your first (ever) G2FUNCS.CMD execution, or if you'
  23. say 'want to rebuild the G2GOISO, G2GOUSA and G2GOEUR packages,'
  24. say 'type yes and press Enter now!'
  25. say 'Otherwise, just press Enter to continue...'
  26. pull answer
  27. if left(answer, 1) = 'Y' then do
  28.    say 'Connecting to SAMPLE database...'
  29.    'DB2 CONNECT TO SAMPLE'
  30.    say 'Creating package G2GOISO (to use ISO Date/Time format)...'
  31.    "DB2 BIND REXXGDB2.BND DATETIME ISO COLLECTION 'G2GOISO'"
  32.    say
  33.    say 'Creating package G2GOUSA (to use USA Date/Time format)...'
  34.    "DB2 BIND REXXGDB2.BND DATETIME USA COLLECTION 'G2GOUSA'"
  35.    say
  36.    say 'Creating package G2GOEUR (to use Europe Date/Time format)...'
  37.    "DB2 BIND REXXGDB2.BND DATETIME EUR COLLECTION 'G2GOEUR'"
  38.    end
  39.  
  40. /*
  41. ------------------------------------------------------------------------
  42.                               G2LoadFuncs
  43. ------------------------------------------------------------------------
  44. */
  45. say line
  46. if rxfuncquery('g2LoadFuncs') then do
  47.    say
  48.    say 'Loading REXXGDB2 Functions...'
  49.    call rxfuncadd 'g2LoadFuncs', 'REXXGDB2', 'g2LoadFuncs'
  50.    say 'Result =' g2LoadFuncs()
  51.    end
  52.  
  53. database = 'Sample'
  54. call G2ConnectReset                    /* disconnect prev. session */
  55. say
  56. say 'Using the default package (ISO Date/Time format)...'
  57. call G2SetCurPkgSet 'G2GOISO'
  58.  
  59. /*
  60. ------------------------------------------------------------------------
  61.                              G2ConnectShare
  62. ------------------------------------------------------------------------
  63. */
  64. say line
  65. say 'Connecting to database' database'...'
  66. call time 'R'
  67. sqlcode = G2ConnectShare(database)
  68. elapse = time('E')
  69. say 'Execution time             =' elapse
  70. say 'Return code (SQLCODE)      =' sqlcode
  71.  
  72. /*
  73. ------------------------------------------------------------------------
  74.                                G2CurDate
  75. ------------------------------------------------------------------------
  76. */
  77. say line
  78. call time 'R'
  79. value  = G2CurDate()
  80. elapse = time('E')
  81. say 'Current Date               =' value
  82. say '        length             =' length(value)
  83. say 'Execution time             =' elapse
  84. say 'G2SQLCODE                  =' G2sqlcode
  85. call wait
  86.  
  87. /*
  88. ------------------------------------------------------------------------
  89.                              G2CurExplSnap
  90. ------------------------------------------------------------------------
  91. */
  92. say line
  93. call time 'R'
  94. value  = G2CurExplSnap()
  95. elapse = time('E')
  96. say 'Current Explain Snapshot   =' value
  97. say '        length             =' length(value)
  98. say 'Execution time             =' elapse
  99. say 'G2SQLCODE                  =' G2sqlcode
  100. call wait
  101.  
  102. /*
  103. ------------------------------------------------------------------------
  104.                              G2SetExplSnap
  105. ------------------------------------------------------------------------
  106. */
  107. say line
  108. say 'Setting Current Explain Snapshot to YES...'
  109. say 'Current Explain... (before)=' G2CurExplSnap()
  110. call time 'R'
  111. value  = G2SetCurExplSnap('Yes')
  112. elapse = time('E')
  113. say 'Execution time             =' elapse
  114. say 'Return code (SQLCODE)      =' sqlcode
  115. say 'Current Explain... (after) =' G2CurExplSnap()
  116.  
  117. say 'Setting Current Explain Snapshot to EXPLAIN...'
  118. call time 'R'
  119. value  = G2SetCurExplSnap('ExPlaiN')
  120. elapse = time('E')
  121. say 'Execution time             =' elapse
  122. say 'Return code (SQLCODE)      =' sqlcode
  123. say 'Current Explain... (now)   =' G2CurExplSnap()
  124. call wait
  125.  
  126. /*
  127. ------------------------------------------------------------------------
  128.                              G2CurFuncPath
  129. ------------------------------------------------------------------------
  130. */
  131. say line
  132. call time 'R'
  133. value  = G2CurFuncPath()
  134. elapse = time('E')
  135. say 'Current Function Path      =' value
  136. say '        length             =' length(value)
  137. say 'Execution time             =' elapse
  138. say 'G2SQLCODE                  =' G2sqlcode
  139. call wait
  140.  
  141. /*
  142. ------------------------------------------------------------------------
  143.                              G2CurQueryOpt
  144. ------------------------------------------------------------------------
  145. */
  146. say line
  147. call time 'R'
  148. value  = G2CurQueryOpt()
  149. elapse = time('E')
  150. say 'Current Query Optimization =' value
  151. say '        length             =' length(value)
  152. say 'Execution time             =' elapse
  153. say 'G2SQLCODE                  =' G2sqlcode
  154. call wait
  155.  
  156. /*
  157. ------------------------------------------------------------------------
  158.                              G2SetQueryOpt
  159. ------------------------------------------------------------------------
  160. */
  161. say line
  162. say 'Setting Current Query Optimization to 0...'
  163. say 'Current Query Opt. (before)=' G2CurQueryOpt()
  164. call time 'R'
  165. value  = G2SetCurQueryOpt(0)
  166. elapse = time('E')
  167. say 'Execution time             =' elapse
  168. say 'Return code (SQLCODE)      =' sqlcode
  169. say 'Current Query Opt. (after) =' G2CurQueryOpt()
  170. call wait
  171.  
  172. /*
  173. ------------------------------------------------------------------------
  174.                               G2CurServer
  175. ------------------------------------------------------------------------
  176. */
  177. say line
  178. call time 'R'
  179. value  = G2CurServer()
  180. elapse = time('E')
  181. say 'Current Server             =' value
  182. say '        length             =' length(value)
  183. say 'Execution time             =' elapse
  184. say 'G2SQLCODE                  =' G2sqlcode
  185. call wait
  186.  
  187. /*
  188. ------------------------------------------------------------------------
  189.                                G2CurTime
  190. ------------------------------------------------------------------------
  191. */
  192. say line
  193. call time 'R'
  194. value  = G2CurTime()
  195. elapse = time('E')
  196. say 'Current Time               =' value
  197. say '        length             =' length(value)
  198. say 'Execution time             =' elapse
  199. say 'G2SQLCODE                  =' G2sqlcode
  200. call wait
  201.  
  202. /*
  203. ------------------------------------------------------------------------
  204.                              G2CurTimeStamp
  205. ------------------------------------------------------------------------
  206. */
  207. say line
  208. call time 'R'
  209. value  = G2CurTimeStamp()
  210. elapse = time('E')
  211. say 'Current Time Stamp         =' value
  212. say '        length             =' length(value)
  213. say 'Execution time             =' elapse
  214. say 'G2SQLCODE                  =' G2sqlcode
  215. call wait
  216.  
  217. /*
  218. ------------------------------------------------------------------------
  219.                              G2CurTimeZone
  220. ------------------------------------------------------------------------
  221. */
  222. say line
  223. call time 'R'
  224. value  = G2CurTimeZone()
  225. elapse = time('E')
  226. say 'Current Time Zone          =' value
  227. say '        length             =' length(value)
  228. say 'Execution time             =' elapse
  229. say 'G2SQLCODE                  =' G2sqlcode
  230. call wait
  231.  
  232. /*
  233. ------------------------------------------------------------------------
  234.                                G2CurUser
  235. ------------------------------------------------------------------------
  236. */
  237. say line
  238. call time 'R'
  239. value  = G2User()
  240. elapse = time('E')
  241. say 'User                       =' value
  242. say 'length                     =' length(value)
  243. say 'Execution time             =' elapse
  244. say 'G2SQLCODE                  =' G2sqlcode
  245. call wait
  246.  
  247. /*
  248. ------------------------------------------------------------------------
  249.                             G2SetConnection
  250. ------------------------------------------------------------------------
  251. */
  252. say line
  253. say 'Setting Connect to' database'...'
  254. call time 'R'
  255. sqlcode = G2SetConnection(database)
  256. elapse = time('E')
  257. say 'Execution time             =' elapse
  258. say 'Return code (SQLCODE)      =' sqlcode
  259. call wait
  260.  
  261. /*
  262. ------------------------------------------------------------------------
  263.                              G2SetCurPkgSet
  264. ------------------------------------------------------------------------
  265. */
  266. say line
  267. say 'Setting Current Packageset to G2GOUSA (U.S.A. DateTime format)...'
  268. say 'Current Date/Time (default)=' G2CurDate() G2CurTime()
  269. call time 'R'
  270. sqlcode = G2SetCurPkgSet('G2GOUSA')
  271. elapse = time('E')
  272. say 'Execution time             =' elapse
  273. say 'Return code (SQLCODE)      =' sqlcode
  274. say 'Current Date/Time (U.S.A.) =' G2CurDate() G2CurTime()
  275. say 'Setting Current Packageset to G2GOEUR (Europe DateTime format)...'
  276. call time 'R'
  277. sqlcode = G2SetCurPkgSet('G2GOEUR')
  278. elapse = time('E')
  279. say 'Execution time             =' elapse
  280. say 'Return code (SQLCODE)      =' sqlcode
  281. say 'Current Date/Time (Europe) =' G2CurDate() G2CurTime()
  282. say 'Setting Current Packageset to G2GOISO (ISO, default DateTime format)...'
  283. call time 'R'
  284. sqlcode = G2SetCurPkgSet('G2GOISO')
  285. elapse = time('E')
  286. say 'Execution time             =' elapse
  287. say 'Return code (SQLCODE)      =' sqlcode
  288. say 'Current Date/Time (default)=' G2CurDate() G2CurTime()
  289. call wait
  290.  
  291. /*
  292. ------------------------------------------------------------------------
  293.                              G2ConnectReset
  294. ------------------------------------------------------------------------
  295. */
  296. say line
  297. say 'Disconnecting...'
  298. call time 'R'
  299. sqlcode = G2ConnectReset()
  300. elapse = time('E')
  301. say 'Execution time             =' elapse
  302. say 'Return code (SQLCODE)      =' sqlcode
  303.  
  304. /*
  305. ------------------------------------------------------------------------
  306.                       G2Immed (using G2Immediate)
  307. ------------------------------------------------------------------------
  308. */
  309. say line
  310. say 'Do you want to continue w/ G2Immed.CMD and other test programs?'
  311. say 'Type No and press Enter to Quit now!'
  312. say 'Just Press Enter otherwise to continue...'
  313. pull answer
  314. if left(answer, 1) = 'N' then return 0
  315.  
  316. say line
  317. call 'G2Immed.CMD'
  318.  
  319. /*
  320. ------------------------------------------------------------------------
  321.                       G2SelectCols (using G2Cols)
  322. ------------------------------------------------------------------------
  323. */
  324. say line
  325. say 'Do you want to continue w/ G2Cols.CMD and other test programs?'
  326. say 'Type No and press Enter to Quit now!'
  327. say 'Just Press Enter otherwise to continue...'
  328. pull answer
  329. if left(answer, 1) = 'N' then return 0
  330.  
  331. say line
  332. call 'G2Cols.CMD'
  333.  
  334. /*
  335. ------------------------------------------------------------------------
  336.                       G2SelectData (using G2Data)
  337. ------------------------------------------------------------------------
  338. */
  339. say line
  340. say 'Do you want to continue w/ G2Data.CMD and other test programs?'
  341. say 'Type No and press Enter to Quit now!'
  342. say 'Just Press Enter otherwise to continue...'
  343. pull answer
  344. if left(answer, 1) = 'N' then return 0
  345.  
  346. say line
  347. call 'G2Data.CMD'
  348.  
  349. /*
  350. ------------------------------------------------------------------------
  351.                       G2SelectForm (using G2Form)
  352. ------------------------------------------------------------------------
  353. */
  354. say line
  355. say 'Do you want to continue w/ G2Form.CMD and other test programs?'
  356. say 'Type No and press Enter to Quit now!'
  357. say 'Just Press Enter otherwise to continue...'
  358. pull answer
  359. if left(answer, 1) = 'N' then return 0
  360.  
  361. say line
  362. call 'G2Form.CMD'
  363.  
  364. /*
  365. ------------------------------------------------------------------------
  366.                        G2SelectOne (using G2One)
  367. ------------------------------------------------------------------------
  368. */
  369. say line
  370. say 'Do you want to continue w/ G2One.CMD and other test programs?'
  371. say 'Type No and press Enter to Quit now!'
  372. say 'Just Press Enter otherwise to continue...'
  373. pull answer
  374. if left(answer, 1) = 'N' then return 0
  375.  
  376. say line
  377. call 'G2One.CMD'
  378.  
  379. /*
  380. ------------------------------------------------------------------------
  381.                       G2DropFuncs (using DropGDB2)
  382. ------------------------------------------------------------------------
  383. */
  384. say line
  385. say 'Do you want to continue w/ DropGDB2.CMD program?'
  386. say 'Type No and press Enter to Quit now!'
  387. say 'Just Press Enter otherwise to continue...'
  388. pull answer
  389. if left(answer, 1) = 'N' then return 0
  390.  
  391. say line
  392. call 'DropGDB2.CMD'
  393.  
  394. /*
  395. ------------------------------------------------------------------------
  396.                                Conclusion
  397. ------------------------------------------------------------------------
  398. */
  399. say
  400. say 'Press Enter now to conclude this program...'
  401. pull answer
  402. 'cls'
  403. say
  404. say "You've just completed all programs to test all functions"
  405. say 'included in REXXGDB2.DLL.'
  406. say
  407. say 'Thank you so much for using the products included in this'
  408. say 'package.'
  409. say
  410. say 'Please read the online document REXXGDB2.INF for a complete'
  411. say 'package information.  That file can be viewed and printed'
  412. say 'through OS/2 VIEW command which you can run from the command'
  413. say 'prompt.'
  414. say
  415. say 'Regards,'
  416. say 'Simon Husin in Kent, Washington, U.S.A., December 1995'
  417. say 'E-mail: husin@ibm.net'
  418. say line
  419. say 'Do you want to view REXXGDB2.INF now?'
  420. say 'Type No and press Enter to Quit now!'
  421. say 'Just Press Enter otherwise to continue...'
  422. pull answer
  423. if left(answer, 1) = 'N' then return 0
  424. 'start /N view REXXGDB2'
  425. return 0
  426.  
  427. error:
  428. if errmsg = '' then
  429.    errmsg = 'Unknown error(s) detected...'
  430. syntax:
  431. if errmsg = '' then
  432.    errmsg = 'Syntax error detected...'
  433. say errmsg
  434. return 10
  435.  
  436. wait:
  437. say 'Press Enter to continue...'
  438. pull xxx
  439. return 0
  440.