Top
NetCOBOL V11.0 Getting Started
FUJITSU Software

4.2 Setting up the SQL Execution Environment

In order for a NetCOBOL SQL application to execute successfully, you must ensure that three separate setup oriented tasks have taken place prior to execution:

  1. Define the SQL databases and tables.

  2. Define ODBC data sources.

  3. Setup NetCOBOL runtime information.

This section gives an overview of these three tasks. The following sections then step you through the details.

Define the SQL Databases and Tables

The SQL database(s) and table(s) must typically be defined prior to execution. Note that the SQL language itself is divided into two separate categories - DDL (Data Definition Language) and DML (Data Manipulation Language). DDL is used to create and delete (drop) tables and apply certain access privileges. DML is used to manipulate data and includes reading, writing, deleting and updating tables, among other things.

NetCOBOL applications generally are DML specific. NetCOBOL does not allow you to code embedded DDL in a COBOL program. You may, however, write NetCOBOL applications using dynamic SQL, which contains DDL statements. See “Using Dynamic SQL” in “Chapter 19. Database (SQL)” of the “NetCOBOL User’s Guide” for more information on dynamic SQL in NetCOBOL programs.

Once your SQL database(s) and table(s) have been set up properly, you must additionally ensure that you have been granted appropriate access and that you are aware of any required user id(s) and password(s) required for accessing the SQL data you desire. If you are unfamiliar with this process, you should consult with your SQL database administrator.

Define ODBC Data Sources

After your SQL database(s) and table(s) have been set up properly, you must define an ODBC data source to be used by your NetCOBOL application. It is important to understand that ODBC acts as a sort of “middle man” between your NetCOBOL application and the actual SQL database(s). The embedded SQL statements contained in your NetCOBOL application are actually compiled into ODBC API (Application Programming Interface) calls to the ODBC software. ODBC then takes care of interfacing to the actual SQL database(s).

The advantage to using ODBC from NetCOBOL is that you are thus able to write a single COBOL program that can access any number of different SQL databases, as this connection is made at runtime. Switching a NetCOBOL application from one vendor’s SQL database system to another is as easy as switching the ODBC data source - no changes are required to the COBOL program itself; it does not have to be recompiled or linked.

The details of creating an ODBC data source are described in the section “Defining an ODBC Data Source” below.

Setup NetCOBOL Runtime Information

Once your SQL database(s) and table(s) have been set up properly, and you have created a proper ODBC data source for your application, you must set up NetCOBOL specific runtime information. This step connects the NetCOBOL application to the proper ODBC data source and contains other information about the SQL database environment you wish to access. This information is contained in a NetCOBOL information (.inf) file which is pointed to at runtime. See the section “Setting Up the COBOL Runtime Information” below for details.