************************************************************************* 
      ** 
      ** Source File Name = regder.cbl  1.2 
      ** 
      ** Licensed Materials - Property of IBM 
      ** 
      ** (C) COPYRIGHT International Business Machines Corp. 1995, 1999  
      ** All Rights Reserved. 
      ** 
      ** US Government Users Restricted Rights - Use, duplication or 
      ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
      ** 
      ** PURPOSE: to REGISTER and DEREGISTER a database. 
      ** 
      ** APIs USED: 
      **        REGISTER        sqlgregs 
      **        DEREGISTER      sqlgdreg 
      ** 
      ** 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. "regder".

       Data Division.
       Working-Storage Section.

           copy "sqlenv.cbl".
           copy "sqlca.cbl".

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

      * Variables for the REGISTER/DEREGISTER APIs 
       77 loc-to-reg    pic s9(4) comp-5.

       Procedure Division.
       Main Section.
           display "Sample COBOL program: regder.cbl".

           display "Enter in your user id : " with no advancing.
           accept SQL-UID.

           display "Enter in your password : " with no advancing.
           accept SQL-PSWD.

           move 0 to SQL-UID-LEN.
           move 0 to SQL-PSWD-LEN.

           inspect SQL-UID tallying SQL-UID-LEN for characters
              before initial " ".
           inspect SQL-PSWD tallying SQL-PSWD-LEN for characters
              before initial " ".

           move SQL-NWBINDERY to loc-to-reg.

      ************ 
      * REGISTER * 
      ************ 
           call "sqlgregs" using
                                 by value       loc-to-reg
                                 by reference   SQLE-REG-NWBINDERY
                                 by reference   sqlca
                           returning rc.
           move "REGISTER" to errloc.
           call "checkerr" using SQLCA errloc.

           display "The database has been successfully REGISTERED"

      ************** 
      * DEREGISTER * 
      ************** 
           call "sqlgdreg" using
                                 by value       loc-to-reg
                                 by reference   SQLE-REG-NWBINDERY
                                 by reference   sqlca
                           returning rc.
           move "DEREGISTER" to errloc.
           call "checkerr" using SQLCA errloc.

           display "The database has been successfully DEREGISTERED".
       End-Main.
           stop run.