************************************************************************* ** ** Source File Name = db_udcs.cbl ** ** Licensed Materials - Property of IBM ** ** (C) COPYRIGHT International Business Machines Corp. 1999, 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 with a user-defined collating sequence, ** then DROP the DATABASE. ** ** A user-defined collating sequence allows the user to specify ** the collating behaviour of the database. This can be used by ** applications that require compatibility to the collating ** behaviour of host database products. For example, simulating ** the collating behaviour, in a DB2/MVS CCSID 500 (EBCDIC ** International) database, in a DB2/CS codepage 819 ** (ISO Latin/1) database, can be achived by specifying ** a collating sequence that maps codepage 819 characters ** to CCSID 500 characters when the database is created. ** ** APIs USED : ** CREATE DATABASE sqlgcrea() ** DROP DATABASE sqlgdrpd() ** ** 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. "db_udcs". Data Division. Working-Storage Section. *--> sqlb0x67.cobol copy "sqle819a.cbl". * collating sequence mapping 819 to 500 copy "sqlutil.cbl". copy "sqlenv.cbl". copy "sqlca.cbl". *<-- * Local Variables 77 rc pic s9(9) comp-5. 77 errloc pic x(80). *--> * Variables for Create/Drop database 77 DBNAME pic x(8) value "dbudcs". 77 DBNAME-LEN pic s9(4) comp-5 value 6. 77 ALIAS pic x(8) value "dbudcs". 77 ALIAS-LEN pic s9(4) comp-5 value 6. 77 PATH pic x(255). 77 PATH-LEN pic s9(4) comp-5 value 0. 77 reserved1 pic 9(4) comp-5 value 0. 77 reserved2 pic s9(4) comp-5 value 0. *<-- Procedure Division. dbudcs-pgm section. display "Sample COBOL Program : DBUDCS.CBL". * setup database description block SQLEDBDESC move SQLE-DBDESC-2 to SQLDBDID. move 0 to SQLDBCCP. move -1 to SQLDBCSS. move SQLE-819-500 to SQLDBUDC. move x"00" to SQLDBCMT. move 0 to SQLDBSGP. move 10 to SQLDBNSG. move -1 to SQLTSEXT. SET SQLCATTS TO NULLS. SET SQLUSRTS TO NULLS. SET SQLTMPTS TO NULLS. * setup database country information * structure SQLEDBCOUNTRYINFO move "ISO8859-1" to SQLDBCODESET. move "En_US" to SQLDBLOCALE. display "CREATing the temporary database DBUDCS ...". display "please wait... this will take a while ...". *--> ****************************** * CREATE DATABASE API called * ****************************** call "sqlgcrea" using by value PATH-LEN by value ALIAS-LEN by value DBNAME-LEN by reference sqlca by value 0 by value 0 by reference SQLEDBCOUNTRYINFO by reference SQLEDBDESC by reference PATH by reference ALIAS by reference DBNAME returning rc. *<-- move "creating the database" to errloc. call "checkerr" using SQLCA errloc. display "Database DBUDCS with a user-defined". display "collating sequence created successfully". display "DROPping the database DBUDCS". *--> **************************** * DROP DATABASE API called * **************************** call "sqlgdrpd" using by value reserved1 by value DBNAME-LEN by reference sqlca by value reserved2 by reference DBNAME returning rc. *<-- move "dropping the database" to errloc. call "checkerr" using SQLCA errloc. end-dbudcs. stop run.