IBM COBOL for Windows provides copybooks that make it easier for you to access databases with ODBC drivers by using ODBC calls from COBOL programs. You can use these copybooks with or without modification.
The copybooks described below are for ODBC Version 3.0. However, Version 2.x copybooks are also supplied, and you can substitute them for the Version 3.0 copybooks if you need to develop applications for ODBC Version 2.x.
| Copybook for Version 3.0 of ODBC | Copybook for Version 2.x of ODBC | Description | Location |
|---|---|---|---|
| ODBC3.CPY | ODBC2.CPY | Symbols and constants | INCLUDE folder for COBOL |
| ODBC3D.CPY | ODBC2D.CPY | DATA DIVISION definitions | ODBC folder in the SAMPLES folder for COBOL |
| ODBC3P.CPY | ODBC2P.CPY | PROCEDURE DIVISION statements | ODBC folder in the SAMPLES folder for COBOL |
Include the paths for the INCLUDE and ODBC folders in the SYSLIB environment variable to ensure that the copybooks are available to the compiler.
ODBC3.CPY defines the symbols for constant values described for ODBC APIs. It maps constants used in calls to ODBC APIs to symbols specified in ODBC guides. You can use this copybook to specify and test arguments and function return values.
ODBC3P.CPY lets you use prepared COBOL statements for commonly used functions for initializing ODBC, handling errors, and cleaning up (SQLAllocEnv, SQLAllocConnect, iwzODBCLicInfo, SQLAllocStmt, SQLFreeStmt, SQLDisconnect, SQLFreeConnect, and SQLFreeEnv).
ODBC3D.CPY contains data declarations used by ODBC3.CPY in the WORKING-STORAGE SECTION (or LOCAL-STORAGE SECTION).
Some COBOL-specific adaptations were made in these copybooks:
To include the copybook ODBC3.CPY, specify a COPY statement in the DATA DIVISION as follows:
Example: sample program using ODBC copybooks
Example: copybook for ODBC data definitions
Example: copybook for ODBC procedures
related references
ODBC names truncated or abbreviated for COBOL