Pro*COBOL Getting Started for Windows Platforms Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index



Go to previous file in sequence Go to next file in sequence

Building Pro*COBOL Applications



For specific information on the capabilities of Pro*COBOL 1.8 for Windows NT/95, refer to the Pro*COBOL Supplement to the Oracle Precompilers Guide and the Programmer's Guide to the Oracle Call Interfaces.

Overview

This chapter describes how to build Oracle database applications using Pro*COBOL.

Building Pro*COBOL Applications

Pro*COBOL 1.8 for Windows NT and Windows 95 converts embedded SQL statements in your COBOL program into standard COBOL code. When you successfully precompile this code, the result is a COBOL program that can be compiled and used to build applications that access an Oracle database.

Building 32-bit (Windows NT and Windows 95) Applications

This section describes how to build Pro*COBOL applications for Windows NT and Windows 95.

Precompiling for WIN32

Use the following syntax to precompile a file with Pro*COBOL 1.8 for Windows NT and Windows 95:

C:\> PROCOB file

By default, if no extension is provided, Pro*COBOL will try to open file.PCO.

If the oname= directive is not specified, Pro*COBOL will generate a file named file.CBL.

Pro*COBOL 32-bit reads PCCCOB.CFG (located in C:\ORANT\PRO18) for directive settings before processing directives supplied in the command line. This file can be modified to include directives for precompiling.

Note This section assumes that you have installed Pro*COBOL under C:\ORANT.

If EXEC SQL INCLUDE statements are used, an include= directive is required.

An option include=C:\ORANT\PRO18\COBOL\INCLUDE is present in the PCCCOB.CFG file so that including SQLCA and ORACA will always work even though no include= is explicitly provided in the command line.

An option comp5 is also present in the PCCCOB.CFG file.

If the option comp5=yes:

If comp5=no:

To see a list of available options and their default values, type the Pro*COBOL executable name at the command prompt:

C:\> PROCOB

To see the option, defaults, and the restrictions (if any) on values, type for each option:

C:\> PROCOB /?

PL/SQL Option

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

  1. Enter the SQLCHECK option and the USERID string to connect on the precompiling command line.
  2. Specify the SQLCHECK=FULL option to check the syntax or semantics of embedded SQL statements and PL/SQL blocks.

  3. Additional Information For an example of a command line string, see Oracle Precompilers Programmer's Guide for more information, or review the PL/SQL MAKE file.

Compiling/Linking for WIN32

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

Using Animator Programs can be compiled and executed from within the Micro Focus 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 Micro Focus COBOL stores binary numbers in Big Endian format. Oracle libraries expect binary numbers to be stored in Little Endian format (machine format).

Compiling and Using CBLLINK to Link the Program By default, Micro Focus subprograms are compiled to be dynamically linked at runtime. In such programs, called subprograms, names are resolved and linked at runtime. The name is resolved by looking for the file subprogram.OBJ or subprogram.DLL. The following commands can be used to build a dynamic linking executable.

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

CBLLINK sample1 C:\ORANT\pro18\lib\sqllib18.lib

These commands produce the executable SAMPLE1.EXE, which can be executed like any other Windows NT or Windows 95 program.

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

Building the Sample Programs

This section describes how to use the basic precompiling, compiling, and linking commands to build sample programs. This section also describes the preparations required for running the Pro*COBOL sample programs. Follow these guidelines when you build Oracle database applications.

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 no such account exists on your database, create one before running the sample programs.

Additional Information See your Oracle Server documentation or your database administrator for more information.

The SCOTT account must also contain the special demonstration tables EMP and DEPT. If the account does not contain these tables, use the DEMOBLD utility to create them. To run DEMOBLD:

  1. Start the local Oracle Database or SQL*Net software if connecting to a remote database.
  2. Connect to the database as user SCOTT with password TIGER using Server Manager or SQL*Plus.
  3. Run the DEMOBLD.SQL script (in the \ORAWIN95\DBS directory or in the \ORANT\DBS directory).

  4. Note If you encounter errors, check to make sure that all paths and filenames reflect the configuration of your system. The commands to run the sample programs assume that the ORAWIN95\PRO18\COBOL\SAMPLES or ORANT\PRO18\COBOL\SAMPLES subdirectory is the current working directory. You may need to modify the sample link script to reflect the configuration of your system. See the section "Compiling/Linking for WIN32" earlier in this chapter for more information.

    Note DEMOBLD.SQL contains constraint options in several statements. You may customize it before running the script.

Building Sample Programs There is a batch file, MAKEIT.BAT, in the sample directory. This batch file does the following for you:

procob iname=%1.pco ireclen=132

cobol %1 /ganim /litlink makesyn "COMP-5" = "COMP";

cbllink %1 /M%1 c:\orant\pro18\lib\sqllib18.lib

To build sample programs, run this batch file with any sample file:

MAKEIT sample1    [do not provide file extension name]

Sample Files The following table contains information about sample files.

DIRECTORY PROGRAM SOURCE HOW TO BUILD (Type the following) DESCRIPTION
\samples sample1.exe sample1.pco makeit sample1 See Pro*COBOL Supplement to the Oracle Precompilers Guide
sample2.exe sample2.pco makeit sample2
sample3.exe sample3.pco makeit sample3
sample4.exe sample4.pco makeit sample4
sample6.exe sample6.pco makeit sample6
sample7.exe sample7.pco makeit sample7
sample8.exe sample8.pco makeit sample8
sample9.exe sample9.pco makeit sample9
sample10.exe sample10.pco makeit sample10
sample11.exe sample11.pco makeit sample11
sampleco.exe sampleco.pco makeit sampleco

Building 16-bit (Windows 3.1) Applications

This section describes how to build Pro*COBOL applications for Windows 3.1.

Precompiling for WIN16

Use the following syntax to precompile a file with Pro*COBOL for Windows 3.1.

[C:\] PROCOB OS=WIN16 file

The OS option is used to compile your program for a designated target operating system. Use OS=WIN16 to generate 16-bit code for Windows 3.1 or OS=WIN32 to generate 32-bit code for Windows NT/95. The default value for OS is WIN32, so you must use the OS=WIN16 option to precompile 16-bit applications.

By default, if no extension is provided, Pro*COBOL will try to open file.PCO.

If the oname= directive is not specified, Pro*COBOL will generate file.CBL.

Pro*COBOL 16-bit reads PCCCOBW.CFG located in C:\ORANT\PRO18 for directive settings before processing directives supplied in the command line. This file can be modified to include directives for precompiling.

Note This section assumes that you have installed Pro*COBOL under C:\ORANT.

If EXEC SQL INCLUDE statements are used, an include= directive is required.

An include=C:\ORANT\PRO18\WIN16\COBOL\INCLUDE is present in the PCCCOBW.CFG file so that including SQLCA and ORACA will work even though no include= is explicitly provided in the command line.

To see a list of available options and their default values, type the Pro*COBOL executable name at the command prompt:

C:\> PROCOB OS=WIN16

To see the option, defaults, and the restrictions (if any) on values, type for each option:

C:\> PROCOB OS=WIN16 /?

PL/SQL Option

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

  1. Enter the SQLCHECK option and the USERID string to connect on the precompiling command line.
  2. Specify the SQLCHECK=FULL option to check the syntax or semantics of embedded SQL statements and PL/SQL blocks.

  3. Additional Information For an example of a command line string, see Oracle Precompilers Programmer's Guide for more information, or review the PL/SQL MAKE file.

Linking Pro*COBOL Applications

When you link Pro*COBOL applications, you use the following types of library files:

Library Type Explanation
Oracle Libraries Oracle libraries are required for applications that access an Oracle database.
Pro*COBOL Libraries Pro*COBOL libraries are required for any application that initially contains embedded EXEC SQL statements or PL/SQL blocks (before precompiling) and are installed in the C:\ORANT\PRO18\WIN16\LIB subdirectory.
Runtime Libraries Runtime libraries are created when you install your COBOL compiler. Runtime libraries are required for any COBOL application, including applications that access the Oracle database.

Pro*COBOL Dynamic Link Libraries

Pro*COBOL application program interface (API) calls are implemented in Dynamic Link Library (DLL) files that Oracle provides. To use the DLLs, you must link your application with the import libraries (.LIB files) that correspond to the Pro*COBOL DLLs. Also, you must make sure that the DLL files are installed on the workstation that is using your Pro*COBOL application. Applications linked with DLLs provide the following benefits over static libraries:

The required library files are listed in the table below.

Library Type Micro Focus Library Name
Shared Runtime System COBLIBW.LIB, COBLIB.LIB, COBW.LIB
Static Linked Runtime System (graphical) LCOBOLW.LIB, LCOBOL.LIB, COBW.LIB
Static Linked Runtime System (character) LCOBOLDW.LIB, LCOBOL.LIB, COBW.LIB

Micro Focus-specific Options Two Micro Focus-specific options are supported by Pro*COBOL: anim and comp5. By default, anim=yes and comp5=yes, so it is not necessary to specify the options when precompiling.

If Anim is used:

If the option comp5=yes:

If comp5=no:

Linking Windows 3.1 Applications

To link a Windows application, you must use the runtime libraries installed with the COBOL compiler.

You must also link with a module definition file, as described in your compiler's documentation. Windows applications that access an Oracle database require no special module statements. The module definition file for the sample Windows application is named WINSAM.DEF.

The following module statements must appear in the file:

Module Definition
NAME names the executable.
DESCRIPTION specifies the filename.
EXETYPE identifies the operating system.
DATA specifies the default attributes for data segments.
CODE specifies default attributes for code segments.
STACKSIZE specifies stack size required to run application.
HEAPSIZE specifies the local heap size.
EXPORTS defines exported functions.

Example: The following example presents the contents of a typical module definition file:

Module Definition
NAME WINSAM
DESCRIPTION Oracle Windows sample program
EXETYPE Windows
DATA Preload fixed multiple
CODE Preload fixed
STACKSIZE 30000
HEAPSIZE 8192
EXPORTS MYWNDPROC

Link Options

The following options can be used to link an Oracle database application:

Option Explanation
/NOD causes the default runtime libraries to be ignored. You must specify runtime libraries at link time as shown in the Dynamic Link Libraries.
/NOE prevents the linker from searching extended dictionaries when resolving references.

The SQL18WIN.LIB library is required to link an Oracle database application.

Also required are Micro Focus (Static or Dynamic) Runtime Libraries.

Setting Stack Size

If you use the Micro Focus Shared Runtime System for your COBOL program, you must set the stack size. To set the stack size, put the following line in your AUTOEXEC.BAT file:

SET COBSW=/S32000

This line sets the COBSW environment variable to a stack size of 32K. The stack size should be at least 32K.

If you choose to use the Micro Focus Static Linked Runtime System, make sure the application's .DEF stack size is set to greater than (>)30K.

Connecting COBOL to Oracle

CBL2ORA.DLW is a COBOL-to-Oracle interface module for Windows installed into your C:\ORANT\PRO18\WIN16\COBOL\SAMPLES directory. If you precompile a program with the default anim=yes, ensure that CBL2ORA.DLW resides either in the same directory as the application, or in a directory specified by the COBDIR environment variable.

Sample Programs

Pro*COBOL 1.8 for 16-bit Windows includes sample programs to demonstrate how to build 16-bit applications.

Note To build GUI applications in 16-bit Windows, use 16-bit Microsoft Visual C++. The PATH environment variable must contain Microsoft Visual C++'s \BIN subdirectory, and the INCLUDE environment variable must contain the \INCLUDE subdirectory of Microsoft Visual C++.

Sample Program Descriptions This section lists the sample programs, their descriptions, and some essential information about how to run them.

SAMPLE.PCO--adds new employee records to the personnel database, and checks the integrity of the database. The employee numbers in the database are automatically selected using the current maximum employee number +10.

The program asks you to enter the following data:

If the record has been successfully inserted, the following is printed:

ename added to department dname as employee # nnnnnn

where ename is the employee name, dname is the department, and nnnnnn is the automatically generated employee number.

WINSAM.PCO--a GUI version of the SAMPLE.PCO program. It adds new employee records to the personnel database. The program checks the integrity of the database.

COBPLS.PCO--demonstrates the use of embedded PL/SQL blocks in a Pro*COBOL application. This program prompts you for an employee name that resides in the database. It then executes a PL/SQL block that returns four SELECT statements.

For example, if you enter the name SMITH, the following information is displayed:

SMITH's job is: CLERK
Hired on: 17 DEC 80
0 people have served longer
Salary is: 800
13 people have a higher salary
Department number is: 20
5 people in the department

Using the Sample Programs These programs, when built, produce an executable file. Before running the sample programs, you must do the following:

Building the Demonstration Tables--To run the Pro*COBOL sample programs, you must have a database account with the username SCOTT, the password TIGER, and the demonstration tables EMP and DEPT. This account is included in the Starter database that is shipped with your Oracle7 Server. If no such account exists on your database, create one before running the sample programs. To do so, consult Oracle7 Server Getting Started for Windows NT.

If your database does not contain these tables, use the DEMOBLD.SQL script to create them. To run DEMOBLD, first use SQL*Plus or Server Manager to connect to the Oracle database. Then, type the following to run the DEMOBLD script:

SQL> @DEMOBLD.SQL

Building the Sample Programs--You can build sample programs in two ways. The first method is to precompile, compile, and link the sample program. You can build Pro*COBOL applications in this manner. The second method is to use the Micro Focus COBOL 3.2 Graphical System Workbench.

Attention Only programs that are made to run in a DOS box in Windows can be built using the second method. Therefore, WINSAM.PCO must be built using the first method. The following two sections illustrate how to build the sample programs using either method.

METHOD I (for WINSAM, SAMPLE, or COBPLS)

  1. Navigate to\ORANT\PRO18\WIN16\COBOL\SAMPLES
    at the command prompt.
  2. Type the following:
  3. PROCOB OS=WIN16 INAME=WINSAM.PCO IRECLEN=132 

    Specify SQLCHECK=FULL to precompile COBPLS.

  4. Compile with 16-bit COBOL compiler.
  5. Link by typing:
  6. LINK @WINSAM.MLN

  7. Compile and link the resource file (if you have a resource file).
  8. Type the following at the command prompt:
  9. RC WINSAM.RC

METHOD II (for SAMPLE and COBPLS only)

  1. Navigate to \ORANT\PRO18\WIN16\COBOL\SAMPLES
    at the command prompt.
  2. Type the following:
  3. PROCOB OS=WIN16 INAME=WINSAM.PCO IRECLEN=132.

    Specify SQLCHECK=FULL to precompile COBPLS.

  4. Choose the Workbench icon in the COBOL 3.2 Graphical System Program Group.
  5. Drag and drop the Project icon in the Template group into the Micro Focus Workbench group.
  6. Type the following in the Name box:
  7. SAMPLE 

    and type the following in the Working Directory box:

    C:\ORANT\PRO18\WIN16\COBOL 

  8. Choose OK.
  9. Drag and drop the SAMPLE Project icon into the Checker icon.
  10. Type the following in the Filename box:
  11. SAMPLE 

  12. Choose OK.
  13. Drag and drop the SAMPLE Project icon into the Build icon.
  14. Select Open from the File menu and open SAMPLE.CFG.
  15. Select Choose EXE type from the Configure menu.
  16. Select DOS in the Environment box and Windows 3.1 in the EXE Type box.
  17. Select Create executable from the File menu. SAMPLEW.EXE is created. Notice that the build utility adds a "W" to the name of the executable.

  18. Note If you want to statically link Micro Focus Runtime libraries to your application, replace the libraries specified in the .MLN file with the Static Linked Runtime libraries listed in Table 3-3.

Running the Sample Programs To run a sample program, ensure your SQL*Net for Windows software is installed and your Oracle7 Server is running. From within Windows, choose Run from the Program Manager File menu and type:

C:\ORANT\PRO18\WIN16\COBOL\SAMPLES\WINSAM.EXE

Exiting the Sample Programs

  1. To exit SAMPLE.EXE and COBPLS.EXE, press [Enter] at either the employee name or the department number prompt.
  2. To exit WINSAM.EXE, double-click on the control menu button.

  3. Additional Information For specific information on the capabilities of Pro*COBOL 1.8 for Windows NT and Windows 95 Development, Windows 3.1 Runtime, refer to Pro*COBOL Supplement to the Oracle Precompilers Guide and Programmer's Guide to the Oracle Call Interface.



Go to previous file in sequence Go to next file in sequence
Prev Next
Oracle
Copyright © 1996 Oracle Corporation.
All Rights Reserved.
Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index