************************************************************************* 
      ** 
      ** Source File Name = migrate.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 : 
      **       an example showing how to use the Migrate API in order to 
      **       migrate a database. 
      ** 
      **    APIs USED : 
      **       MIGRATE DATABASE                       sqlgmgdb() 
      ** 
      ** 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. "migrate".

       Data Division.
       Working-Storage Section.

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

      * variables used for MIGRATE API 
       01 database.
         49 database-length       pic s9(4) comp-5 value 0.
         49 database-name         pic x(9).

       01 usr.
         49 usrid-length   pic s9(4) comp-5 value 0.
         49 usrid-name     pic x(19).

       01 passwd.
         49 passwd-length   pic s9(4) comp-5 value 0.
         49 passwd-name     pic x(19).

      * Local Variables 

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

       Procedure Division.
       migrate-pgm section.

           display "Sample COBOL Program : migrate.cbl".

           display "Enter the name of the database : " with no advancing.
           accept database-name.
           inspect database-name tallying database-length for characters
              before initial " ".
           display " ".

           display "Enter in your user id : " with no advancing.
           accept usrid-name.

           inspect usrid-name tallying usrid-length for characters
              before initial " ".
           display " ".

           display "Enter in your password : " with no advancing.
           accept passwd-name.

           inspect passwd-name tallying passwd-length for characters
              before initial " ".
           display " ".

      ********************************* 
      * MIGRATE DATABASE API called   * 
      ********************************* 
           call "sqlgmgdb" using
                                 by value     passwd-length
                                 by value     usrid-length
                                 by value     database-length
                                 by reference sqlca
                                 by reference passwd-name
                                 by reference usrid-name
                                 by reference database-name
                           returning rc.
           if sqlcode equal SQLE-RC-MIG-OK
              go to migrate-complete.
           move "MIGRATE DATABASE" to errloc.
           call "checkerr" using SQLCA errloc.

       migrate-complete.
           display "Migrate Database completed successfully".

       end-migrate. stop run.