Pro*COBOL Precompiler Getting Started for Windows
Release 9.0.1 for Windows

Part Number A90168-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

2
Building Pro*COBOL Applications

This chapter provides an overview of building Oracle database applications with Pro*COBOL releases 9.0.1 and 1.8.52 for Windows operating systems.

This chapter contains these topics:

Precompiling Pro*COBOL Applications

This section describes the basics of precompiling a Pro*COBOL application.

See Also:

See the Pro*COBOL Precompiler Programmer's Guide for more information about Pro*COBOL commands, precompiler options, and configuration files. 

The Pro*COBOL Commands

You can use one of these commands to precompile a file:

Use...  For Pro*COBOL Release... 

procob filename 

9.0.1 

procob18 filename 

1.8.52 

By default, if no extension is provided, Pro*COBOL tries to open filename.pco. If the ONAME option is not specified, Pro*COBOL generates a filenamed filename.cbl.

Precompiler Options

Many useful options are available at precompile time. Included are options that allow you to determine how:

Viewing the Available Options

To see a list of available options and their default values, enter the following at the command prompt:

C:\> procob

To see the option, defaults, and the restrictions (if any) on values, enter the following at the command prompt:

C:\> procob /?

Configuration Files

Pro*COBOL reads the configuration file for options before processing options supplied at the command line.

The configuration file has the following two options:

Check the following table to see whether you should change the value of COMP-5:

If you are using MERANT Micro Focus COBOL... 

COMP-5 can be set to yes (COMP-5=yes) or no (COMP-5=no).

If COMP-5=yes:

  • All COMP data items (if they are potential host variables) are converted to COMP-5.

  • All data items generated by the precompiler will be declared as COMP-5.

If COMP-5=no:

  • The precompiler ignores COMP-5 host variables.

  • Precompiled files generally do not run on Intel platforms.

Workaround: During the compilation stage, use the MERANT Micro Focus COBOL compiler directive:

MAKESYN "COMP-5" = "COMP"

This statement directs the compiler to treat COMP items as if they are COMP-5 items. 

The INCLUDE option enables the provided .cob files in the ORACLE_BASE\ ORACLE_HOME \precomp\public directory to be included without an explicit INCLUDE= option at the command line.

Embedding PL/SQL

If you are using embedded PL/SQL blocks, do the following:

  1. Enter the SQLCHECK option and the USERID string to connect at the precompiling command line.

  2. Specify the SQLCHECK=FULL option to check the syntax or semantics of embedded SQL statements and PL/SQL blocks.

    See Also:

    For an example of a command line string, see the Pro*COBOL Precompiler Programmer's Guide or review the PL/SQL MAKE file. 

Compiling and Linking Pro*COBOL Applications

This section describes how to compile and link Pro*COBOL applications using the following compiler:

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:

MAKESYN "COMP-5" = "COMP"

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

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:

MAKESYN "COMP-5" = "COMP"

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:

 COBOL sample1 /MAKESYN"COMP-5"="COMP";
 CBLLINK sample1

For static linking, the commands are:

 COBOL sample1 /LITLINK /MAKESYN"COMP-5"="COMP";
 CBLLINK sample1 ORACLE_BASE\ORACLE_HOME\precomp\lib\orasql9.lib

The previous commands produce sample1.exe, which can be executed like any other Windows NT, Windows 2000, or Windows 95/98 program.


Note:

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:

PREPROCESS(COBSQL) COBSQLTYPE=ORACLE8 ENDP

or the short form:

P(COBSQL) CSQLT=ORA8 ENDP

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 Tables

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.0.1, the batch files are located in ORACLE_BASE\ORACLE_HOME \precomp\demo\procob2. For release 1.8.52, the files are located in ORACLE_BASE\ORACLE_HOME \precomp\demo\procob.

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 filenames 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 directories:

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.

makeit.bat

The makeit.bat for release 9.0.1 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\orasql9.lib

For release 1.8.52, this batch file contains the following:

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

Sample Files

The Pro*COBOL sample files listed in Table 2-1, "Pro*COBOL Sample Programs" are located in the ORACLE_BASE\ORACLE_HOME \precomp\demo\procob2 (release 9.0.1) and/or ORACLE_BASE\ORACLE_HOME\precomp\demo\procob (release 1.8.52) directories. The SQL scripts are located in the ORACLE_BASE\ORACLE_HOME \precomp\demo\sql directory.

Table 2-1 Pro*COBOL Sample Programs
Sample Program  Description 

sample1.pco 

Simple query 

sample2.pco 

Cursor operations 

sample3.pco 

Host tables 

sample4.pco 

Datatype equivalence 

sample6.pco 

Dynamic SQL Method 1 

sample7.pco 

Dynamic SQL Method 2 

sample8.pco 

Dynamic SQL Method 3 

sample9.pco 

Stored procedure call 

calldemo.sql 

Stored procedure call 

sample10.pco 

Dynamic SQL Method 4 

sample11.pco  

Cursor variable operations 

sample11.sql 

Cursor variable operations 

sample12.pco 

Dynamic SQL Method 4 using ANSI dynamic SQL 

sample13.pco 

Nested program 

sampleco.pco 

Simple query and insert 

sample14.pco 

Host table x (release 8.1.6 and on) 

lobdemo1.pco 

LOB datatypes (release 8.1.6 and on) 

lobdemo1.sql 

LOB datatypes (release 8.1.6 and on) 


Go to previous page Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback