Pro*COBOL Getting Started for Windows Platforms | ![]() Library |
![]() Product |
![]() Contents |
![]() Index |
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.
This chapter describes how to build Oracle database applications using Pro*COBOL.
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.
This section describes how to build Pro*COBOL applications for Windows NT and Windows 95.
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.
Workaround: During the compilation stage, use the Micro Focus compiler directive:
This directs the compiler to treat COMP items as if they are COMP-5 items.
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 /?
If you are using embedded PL/SQL blocks, do the following:
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. |
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. |
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:
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.
This section describes how to build Pro*COBOL applications for Windows 3.1.
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 /?
If you are using embedded PL/SQL blocks, do the following:
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. |
When you link Pro*COBOL applications, you use the following types of library files:
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.
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.
Note To use Micro Focus Animator for debugging, you must link your application with the shared runtime libraries provided by Micro Focus COBOL. |
Note CBL2ORA.DLW is supplied by Micro Focus. If you encounter problems animating Pro*COBOL-generated files, contact Micro Focus for assistance. |
Workaround: During the compilation stage, use the Micro Focus compiler directive:
This directs the compiler to treat COMP items as if they are COMP-5 items.
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:
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 |
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.
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.
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.
Pro*COBOL 1.8 for 16-bit Windows includes sample programs to demonstrate how to build 16-bit applications.
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.
PROCOB OS=WIN16 INAME=WINSAM.PCO IRECLEN=132
Specify SQLCHECK=FULL to precompile COBPLS.
LINK @WINSAM.MLN
RC WINSAM.RC
PROCOB OS=WIN16 INAME=WINSAM.PCO IRECLEN=132.
Specify SQLCHECK=FULL to precompile COBPLS.
SAMPLE
and type the following in the Working Directory box:
C:\ORANT\PRO18\WIN16\COBOL
SAMPLE
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
![]() ![]() Prev Next |
![]() Copyright © 1996 Oracle Corporation. All Rights Reserved. |
![]() Library |
![]() Product |
![]() Contents |
![]() Index |