************************************************************************* ** ** Source File Name = sws.cbl ** ** Licensed Materials - Property of IBM ** ** (C) COPYRIGHT International Business Machines Corp. 1995, 2000 ** All Rights Reserved. ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with ** ** PURPOSE : ** to demonstrate the use of the DATABASE MONITOR SWITCH API. ** ** APIs USED : ** DATABASE MONITOR SWITCH sqlgmon() ** ** ** For more information about these samples see the README file. ** ** For more information on Programming in COBOL, see the: ** - "Programming in COBOL" section of the Application Development Guide. ** ** For more information on Building COBOL Applications, see the: ** - "Building COBOL Applications" section of the Application Building Guide. ** ** For more information on the SQL language see the SQL Reference. ** ************************************************************************* Identification Division. Program-Id. "sws". Data Division. Working-Storage Section. copy "sqlutil.cbl". copy "sqlca.cbl". copy "sqlmonct.cbl". copy "sqlmon.cbl". * Variables for catalog/uncatalog nodes * Local Variables 77 rc pic s9(9) comp-5. 77 errloc pic x(80). 77 rezerv1 pic 9(9) comp-5 value 0. 77 rezerv2 pic 9(9) comp-5 value 0. 77 current-version pic 9(9) comp-5 value 0. Procedure Division. sws-pgm section. display "Sample COBOL Program : sws.cbl". * Initialize - table switches ON, UOW switch OFF, others default move SQLM-ON to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-TABLE-SW). move SQLM-OFF to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-UOW-SW). move SQLM-HOLD to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-STATEMENT-SW). move SQLM-HOLD to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-BUFFER-POOL-SW). move SQLM-HOLD to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-LOCK-SW). move SQLM-HOLD to INPUT-STATE of SQLM-RECORDING-GROUP(SQLM-SORT-SW). move SQLM-CURRENT-VERSION to current-version. ************************************** * DATABASE MONITOR SWITCH API called * ************************************** call "sqlgmon" using by value rezerv1 by reference SQLCA by reference SQLM-RECORDING-GROUP by reference rezerv2 by value current-version returning rc. move "MONITOR SWITCH" to errloc. call "checkerr" using SQLCA errloc. display "Print Switch Values". perform print-sws. display "Print their switch set time (if on)". perform print-sws-set-times. end-sws. stop run. print-sws Section. *********************** * print switch values * *********************** display "SQLM-UOW-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-UOW-SW). display "SQLM-STATEMENT-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-STATEMENT-SW). display "SQLM-TABLE-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-TABLE-SW). display "SQLM-BUFFER-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-BUFFER-POOL-SW). display "SQLM-LOCK-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-LOCK-SW). display "SQLM-SORT-SW : " , OUTPUT-STATE of SQLM-RECORDING-GROUP(SQLM-SORT-SW). end-print-sws. exit. print-sws-set-times Section. ******************************** * print switch set times if on * ******************************** if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-UOW-SW) not equal 0 then display "SQLM-UOW-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-UOW-SW). if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-STATEMENT-SW) not equal 0 then display "SQLM-STATEMENT-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-STATEMENT-SW). if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-TABLE-SW) not equal 0 then display "SQLM-TABLE-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-TABLE-SW). if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-BUFFER-POOL-SW) not equal 0 then display "SQLM-BUFFER-POOL-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-BUFFER-POOL-SW). if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-LOCK-SW) not equal 0 then display "SQLM-LOCK-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-LOCK-SW). if SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-SORT-SW) not equal 0 then display "SQLM-SORT-SW start-time : " , SECONDS of START-TIME of SQLM-RECORDING-GROUP(SQLM-SORT-SW). end-print-sws-set-times. exit.