************************************************************************* 
      ** 
      ** Source File Name = dbmconf.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 : 
      **       This program is an example of how APIs are implemented in order 
      **       to CREATE a DATABASE and then GET the CONFIGURATION information 
      **       from it, then UPDATE the CONFIGURATION, RESET the CONFIGURATION, 
      **       then DROP the DATABASE. 
      ** 
      **       This program can only be run locally. 
      ** 
      **    APIs USED : 
      **       GET DATABASE MANAGER CONFIGURATION          sqlgxsys() 
      **       UPDATE DATABASE MANAGER CONFIGURATION       sqlgusys() 
      **       RESET DATABASE MANAGER CONFIGURATION        sqlgrsys() 
      **       GET ADDRESS                                 sqlgaddr() 
      ** 
      ** 
      ** 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. "dbmconf".

       Data Division.
       Working-Storage Section.
       copy "sqlutil.cbl".
       copy "sqlca.cbl".

      * Local Variables 
       77 rc                  pic s9(9) comp-5.
       77 errloc              pic x(80).

       77 user-response       pic x.

       01 dbname              pic x(8) value "sample".
       01 dbname-len          pic s9(4) comp-5 value 6.

       01 max-agents          pic 9(9) comp-5.
       01 numbdb              pic s9(4) comp-5.
       01 svcename            pic x(14).
       01 tpname              pic x(64).

      * variables for GET/UPDATE/RESET database manager configuration 
       01 listnumber          pic s9(4) comp-5 value 2.

       01 list-of-lengths.
          05 token-length occurs 2 times pic 9(9) comp-5.

       01 tokenlist.
          05 tokens occurs 2 times.
             10 token         pic 9(4) comp-5.
             10 filler        pic x(2).
             10 tokenptr      usage is pointer.

       Procedure Division.
       dbmconf-pgm section.

           display "Sample COBOL Program : dbmconf.cbl".

           move SQLF-KTN-MAXAGENTS  to token(1).
           move SQLF-KTN-NUMDB      to token(2).

           move "GET ADDRESS" to errloc.
      ************************** 
      * GET ADDRESS API called * 
      ************************** 
           call "sqlgaddr" using by reference max-agents
                                 by reference tokenptr(1)
                           returning rc.

           call "sqlgaddr" using by reference numbdb
                                 by reference tokenptr(2)
                           returning rc.

           display "getting the default Database Manager Configuration".
      ************************************************* 
      * GET DATABASE MANAGER CONFIGURATION API called * 
      ************************************************* 
           call "sqlgxsys" using by value     listnumber
                                 by reference tokenlist
                                 by reference sqlca
                           returning rc.
           move "get database manager config" to errloc.
           call "checkerr" using SQLCA errloc.

           display "listing the database configuration".
           perform print-info.

           display "*****************************". 
           display "*** IMPORTANT INFORMATION ***". 
           display "*****************************". 
           display " ".
           display "In the following steps of this program, an UPDATE ".
           display "and a RESET database manager configuration API will".
           display "be called, changing the current database manager".
           display "configuration to be reset to the DEFAULT values".
           display " ".
           display "Do you wish to continue? (y/n) : " with no advancing.
           accept user-response.
           display "user-response : ", user-response.

           if user-response not equal to "y" and not equal to "Y"
           then stop run.

      * Altering values of the default Database Manager Configuration 
           move 150 to max-agents.
           move 15   to numbdb.
      *************************************************** 
      * UPDATE DATABSE MANAGER CONFIGURATION API called * 
      *************************************************** 
           call "sqlgusys" using by value     listnumber
                                 by reference list-of-lengths
                                 by reference tokenlist
                                 by reference sqlca
           move "updating the database manager config" to errloc.
           call "checkerr" using SQLCA errloc.

           display "listing the UPDATEd Database Manager Configuration".
      *************************************************** 
      * GET DATABASE MANAGER CONFIGURATION API called * 
      *************************************************** 
           call "sqlgxsys" using by value     listnumber
                                 by reference tokenlist
                                 by reference sqlca
                           returning rc.
           move "get the database manager config" to errloc.
           call "checkerr" using SQLCA errloc.

           display "listing the database configuration".
           perform print-info.

           display "RESETing the Database Manager Configuration".
      *************************************************** 
      * RESET DATABASE MANAGER CONFIGURATION API called * 
      *************************************************** 
           call "sqlgrsys" using by reference sqlca
                           returning rc.
           move "reset the database manager config" to errloc.
           call "checkerr" using SQLCA errloc.


           display "listing the RESETed Database Manager Configuration".
      *************************************************** 
      * GET DATABASE MANAGER CONFIGURATION API called * 
      *************************************************** 
           call "sqlgxsys" using by value     listnumber
                                 by reference tokenlist
                                 by reference sqlca
                           returning rc.
           move "get the database manager config" to errloc.
           call "checkerr" using SQLCA errloc.

           display "listing the database configuration".
           perform print-info.

       end-dbmconf. stop run.

      * PRINT DATABASE MANAGER CONFIGURATION INFORMATION 
       print-info Section.

           display "Max. number of Agents                  : ",
                    max-agents.
           display "Number of concurrent active DB allowed : ",
                    numbdb.

       end-print-info. exit.