HPlogo ALLBASE/SQL COBOL Application Programming Guide: HP 9000 Computer Systems > Chapter 1 Getting Started with ALLBASE/SQL Programming in COBOL

The Compiler and the Runtime System

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

COBOL source code which has been modified by the ALLBASE/SQL COBOL Preprocessor can be compiled and executed in two different ways, using either static linking or dynamic linking of runtime routines.

The syntax of the following components are required to produce an executable program.

filename.cbl

COBOL source code which has been modified by the ALLBASE/SQL COBOL Preprocessor.

filename.sqlc

preprocessor-generated file, defining variables with a VALUE clause which are referenced by ALLBASE/SQL.

filename.sqlv

preprocessor-generated file, defining all other variables which are referenced by ALLBASE/SQL.

libsql.a

library of ALLBASE/SQL runtime routines (resides in directory /usr/include).

libportnls.a

library of native language runtime routines (resides in directory /usr/include).

libcl.a

library of PASCAL runtime routines (resides in directory /usr/include).

nonCOBOLprog.o

compiled object code for any non-COBOL subprograms incorporated in the COBOL application program.

sqlcall.c

C language source code which defines the call interface to ALLBASE/SQL runtime routines (resides in directory /usr/include).

NOTE: For C language subprograms, source code files (nonCOBOLprog.c) may be substituted in place of object code files in COBOL compiler commands.

The special things you need to know about sqlcall.c are:

  • COBOL/HP-UX requires a call number in the range of 0 to 127 for each non-COBOL subprogram. ALLBASE/SQL uses call number 120, as defined in files /usr/include/sqlcall.h and /usr/include/sqlcall.cbl. If other non-COBOL subprograms are incorporated in the COBOL application, sqlcall.c must be modified to include a call number for each non-COBOL subroutine.

  • An object code file, sqlcall.o, may be substituted in place of sqlcall.c in COBOL/HP-UX compiler commands. The C language compiler command to create an object module is:

    
    
    	       cc -c sqlcall.c
    

  • To be properly referenced by the COBOL/HP-UX compiler, a copy of sqlcall (either source or object code) should be placed in the local directory where the COBOL application program is being compiled.

Figure 1-4 summarizes the steps for compiling and executing a COBOL application program with static linking of runtime routines. This process generates an executable file. For more information, refer to the COBOL/HP-UX Operating Manual.

Figure 1-4 Compiling and Executing a COBOL Application Program with Static Linking of Runtime Routines

[Compiling and Executing a COBOL Application Program with Static Linking of Runtime Routines]

The following syntax illustrates the commands used to compile and execute a COBOL application with static linking of runtime routines.

Step 1

Invoke the ALLBASE/SQL COBOL preprocessor.



   psqlcbl dbename -i progname.sql [other preprocessor options]

Step 2

Compile and link the modified source code, creating an executable module (progname).

cob progname.cbl { sqlcall.c sqlcall.o } [ nonCOBOLprog.c nonCOBOLprog.o ] |...| -lsql -lportnls +lcl -x

Step 3

Run the executable file.



   progname

Example



   $ psqlcbl dbename -i progname.sql -m progmodule -d 

   $ cob progname.cbl sqlcall.c nonCOBOLprog.c -lsql -lportnls +lcl -x

Figure 1-5 summarizes the steps for compiling and executing a COBOL application program with dynamic linking of runtime routines. This process generates an file of compiled intermediate code, which is executed by a customized COBOL runtime system. For more information, refer to the COBOL/HP-UX Operating Manual.

Figure 1-5 Compiling and Executing a COBOL Application Program with Dynamic Linking of Runtime Routines

[Compiling and Executing a COBOL Application Program with Dynamic Linking of Runtime Routines]

The following syntax illustrates the syntax of commands used to compile and execute a COBOL application with dynamic linking of runtime routines.

Step 1

Using the COBOL/HP-UX compiler, create the customized COBOL runtime system containing the runtime routines which will be dynamically linked to the application at runtime. This step only needs to be performed once, unless subprograms have changed.

cob { sqlcall.c sqlcall.o } [ nonCOBOLprog.c nonCOBOLprog.o ] |...| -lsql -lportnls +lcl -x -e "" -o sqlrun

Step 2

Invoke the ALLBASE/SQL COBOL preprocessor.



   psqlcbl dbename -i progname.sql [other preprocessor options]

Step 3

Compile the modified COBOL source code, creating a module of intermediate code (progname.int).



   cob progname.cbl -i

Step 4

Using the customized runtime system created in step 3, execute the intermediate code generated by the COBOL/HP-UX compiler.



   sqlrun progname.int

Example



   $ cob sqlcall.c nonCOBOLprog.c -lsql -lportnls +lcl -x -e "" -o sqlrun

   $ psqlcbl dbename -i progname.sql -m progmodule -d

   $ cob progname.cbl -i

   $ sqlrun progname.int

ALLBASE/SQL COBOL requires that each non-COBOL subprogram be assigned a call number in the range of 0 to 127. ALLBASE/SQL uses 120. Thus, if you have previously used 120 for one of your subprograms, you can resolve the conflict in one of two ways:

  • Modify your subprogram call number to a non-conflicting value.

or

  • Modify the system copy files, /usr/include/sqlcall.cbl and /usr/include/sqlcall.h. These two files define the ALLBASE/SQL subprogram's call number. To change the ALLBASE/SQL call number, merely alter the number in these two files, recompile sqlcall.c (sqlcall.h is included in sqlcall.c) and link the Runtime System as mentioned previously.