Skip Headers
Pro*COBOL® Programmer's Guide
11g Release 2 (11.2)

Part Number E10826-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

F Pro*COBOL for Windows

This section provides an overview of building Oracle database applications with Pro*COBOL Release 9.2 for Windows operating systems.

This section contains these topics:

Compiling and Linking Pro*COBOL Applications

Pro*COBOL supports the MERANT Micro Focus NetExpress version 4.0 for 32-bit Windows 2000. This section describes how to compile and link Pro*COBOL applications using the MERANT Micro Focus compiler.

You can build and execute a MERANT Micro Focus COBOL application in two ways:

In each of these the COBSQL utility may be used with the following advantages:

How to Use the IDE

A program generated by Pro*COBOL can be compiled and executed from within the MERANT Micro Focus NetExpress IDE. Simply add the .cbl file generated by Pro*COBOL to a Net Express project. To avoid potential inconsistencies when calling routines in the Oracle libraries the program should be compiled using the directive:


This directive can be specified in the build setting for the source file, the project settings or through a $SET line at the start of the source file. When you select Rebuild or Rebuild All the IDE generates an executable ready to Run or Animate.

How to Use the Animator Products

Programs can be compiled and executed from within the MERANT Micro Focus COBOL debugger, Animator V2.

To avoid potential inconsistencies when calling routines in the Oracle libraries, select the menu option Compiler Directives, and enter:

This step is required because MERANT Micro Focus COBOL stores binary numbers in Big Endian format. Oracle libraries expect binary numbers to be stored in Little Endian format (machine format).


The COBOL and CBLLINK Commands

COBOL and CBLLINK can be used to build programs in two ways, depending on whether the Pro*COBOL runtime is to be statically linked or accessed through a DLL at runtime.

For dynamic linking, the commands are:

 CBLLINK sample1

For static linking, the commands are:

 CBLLINK sample1 ORACLE_BASE\ORACLE_HOME\precomp\lib\orasql11.lib

The previous commands produce sample1.exe, which can be executed like any other Windows 2000 program.


MERANT Micro Focus COBOL must be installed on the same system as Pro*COBOL to successfully execute the file.

The COBSQL Command

COBSQL can be used to simplify preprocessing and debugging. To use COBSQL, specify the following directive to the COBOL compiler:


or the short form:


COBSQLTYPE should be set to ORACLE or ORA for versions of Pro*COBOL prior to release 8.0. The directive may be set with a $SET line at the start of the source file, on the COBOL command line, in program build settings or project settings for NetExpress, or with SQL compiler directives settings for Animator. At compile time, COBSQL runs Pro*COBOL as a background task and passes its output to the COBOL compiler together with additional information required to enable Animator to track execution using the .pco file rather than .cbl file.

When using COBSQL there is no need to deal directly with the .cbl file. Instead, add the .pco file to a NetExpress project, or open it with Animator.

Sample Programs

Oracle provides sample programs to demonstrate the use of Pro*COBOL with Oracle database features. See "Sample Files" for a listing of these programs.

This section describes how to use the basic precompiling, compiling, and linking commands to build the sample programs. This section also describes the preparations required for running the Pro*COBOL sample programs.

Building the Demonstration Table

To run the Pro*COBOL sample programs, you must have a database account with the username scott and the password tiger. If this account does not exist on your database, create one before running the sample programs.

The scott account must contain the emp and dept tables. If the account does not contain these tables, use the demobld.sql script to create them.

To run the demobld.sql script:

  1. Start SQL*Plus.

  2. Connect to the database as username scott with password tiger.

  3. Run the demobld.sql script. For example:

    SQL> @ORACLE_BASE\ORACLE_HOME\sqlplus\demo\demobld.sql

Building the Sample Programs

Pro*COBOL supplies the makeit.bat file which is listed in the next section, for building a MERANT Micro Focus COBOL sample file:

For release 9.2.0, the batch files are located in ORACLE_BASE\ORACLE_HOME \precomp\demo\procob2.

To build the sample programs:

  1. Run the batch files with any sample file. Do not include the file extension. For example:

    C:\ORACLE\ORA90\PRECOMP\DEMO\PROCOB2> makeit sample1
  2. Ensure that all paths and file names reflect the configuration of your system, if you encounter errors when building a sample program.

The commands to run the sample programs assume that the following are the current working directory:

ORACLE_BASE\ORACLE_HOME \precomp\demo\procob2 directory for release 9.2.0

You may need to modify the sample link script to reflect the configuration of your system. See "Compiling and Linking Pro*COBOL Applications" for more information.

The makeit.bat for release 9.2.0 contains the following:

procob iname=%1.pco ireclen=132 
cobol %1 /anim /litlink makesyn "COMP-5" = "COMP"; 
cbllink %1 /M%1 ORACLE_BASE\ORACLE_HOME\precomp\lib\orasql11.lib

Sample Files

The Pro*COBOL sample files listed in Table F-1 are located in the ORACLE_BASE\ORACLE_HOME\precomp\demo\procob2 (release 9.2.0) directory. The SQL scripts are located in the ORACLE_BASE\ORACLE_HOME\precomp\demo\sql directory.

Table F-1 Pro*COBOL Sample Programs

Sample Program Description


Simple query


Cursor operations


Host tables


Datatype equivalence


Dynamic SQL Method 1


Dynamic SQL Method 2


Dynamic SQL Method 3


Stored procedure call


Stored procedure call


Dynamic SQL Method 4


Cursor variable operations


Cursor variable operations


Dynamic SQL Method 4 using ANSI dynamic SQL


Nested program


Simple query and insert


Host table x (release 8.1.6 and on)


LOB datatypes (release 8.1.6 and on)


LOB datatypes (release 8.1.6 and on)