A quick overview of the components of ODBC will help you interface your COBOL program to ODBC-compliant data sources.
ODBC requires four components: an ODBC-enabled application, the ODBC driver manager, ODBC database drivers, and data sources. The following diagram indicates how these components work together in a single-tier environment.
The following diagram indicates how these components work together in a multiple-tier environment.
Application
The application is your COBOL program, or more precisely, the ACUCOBOL-GT run-time system together with Acu4GL for ODBC. The run-time system generates the appropriate SQL queries to accomplish the file I/O task that your COBOL program is executing. This includes all file positioning and record locking. When the query results are returned to the ACUCOBOL-GT run-time system, they are mapped either to a COBOL record or to the appropriate COBOL status code, if one exists.
Driver Manager
The driver manager loads the ODBC driver. The driver manager then passes requests to the driver and returns results to the ACUCOBOL-GT run-time system. For the Microsoft Windows environment, the driver manager is called ODBC32.DLL for 32-bit architectures.
The driver manager is typically included with the ODBC driver and is often installed along with the driver. For some products, such as Microsoft Access and Excel, the driver manager is installed automatically if you choose the ODBC support option while installing the product. (The ODBC support option tends to be part of the custom install process.)
Driver
The driver processes ODBC requests and returns data to the driver manager and your application. If necessary, the driver translates the run-time system’s SQL request into a form that is understood by the target data source.
Your application is not limited to communicating through just one driver, however. By setting the ACUFH configuration variable A_ODBC_DATASOURCE, you can direct the ACUCOBOL-GT run-time system to connect to a different driver for any given file. Simply set this variable before opening the indexed data file. The Acu4GL interface for ODBC will then handle connecting to the new data source and performing any operations necessary to open the file.
The driver is the most important feature of ODBC. ODBC drivers for a given data source may be available from many different vendors. They vary greatly in performance and in the options they provide for a given data source. Be sure to carefully review a data source driver to determine its level of performance.
Your Acu4GL for ODBC disks include a program that tests your ODBC driver for the various functions the Acu4GL product requires. This program is called DRVTST32.EXE. You initiate it by selecting the appropriate icon in the Acu4GL for ODBC program group. Please see Driver Requirements for instructions on using the driver test program. This topic also describes the minimal requirements that your driver must meet to work with Acu4GL for ODBC.
Data Sources
Data sources are the files or databases accessed by a driver. Each data source must be identified during setup.
Some data sources are simple to identify. For example, to access a text file, you would provide the name and location of the file. Some are more complex, though. For example, to access a UNIX-hosted database such as Oracle, you would identify the Windows drivers, Windows applications, network connections, and database information.
In Windows, you set up an ODBC data source in the Windows control panel, Administrative Tools dialog. After you double-click the Data Sources (ODBC) icon, an ODBC Data Source Administrator dialog is displayed. You must designate the driver, the data source, and any other information necessary to access the data. Setup procedures are described in detail in the Installation section.
The following diagram shows how the Acu4GL product fits into a single-tier environment.
The following diagram shows how Acu4GL fits into a multiple-tier environment.