HP 3000 Manuals

Compiling [ Micro Focus COBOL for UNIX COBOL User Guide ] MPE/iX 5.0 Documentation


Micro Focus COBOL for UNIX COBOL User Guide

Compiling 

Compiling your SQL program with the COBOL Compiler is logically
equivalent to two steps:  precompiling to change SQL lines into host
language statements, and then compiling the resulting source.  These two
steps actually occur in a single process, which is performed by the COBOL
system.

You use Compiler directives to tell the COBOL system that you are using
SQL, which database you are using and so on.  These directives are
summarized later in this chapter.

Normally, programs containing embedded SQL are compiled in the same way
as other non-SQL programs, except that the additional directives are
required.  Special action is required only when creating any executable
(binary) file when additional modules need to be linked in.  Programs
containing SQL code can be animated like any other program.  You can
examine host variables inside SQL statements as they are regular COBOL
data items.

Windows and      On Windows and OS/2, if you are not creating an
OS/2             executable file (that is one which can be animated or
                 run), set the SQLPRE Compiler directive to either
                 SQLPRE(ALL) (the default value) or SQLPRE(REQ). These
                 values cause a module to be called to preload the
                 required database engine support calls for IBM only.

For Database Manager on OS/2, if your program contains only EXEC SQL
statements (and not direct API calls to the database engine) select the
SQLPRE(REQ) settings which can reduce the program's memory requirement
and start-up time.  If you are creating an executable file, this
directive can affect the stack size that is created; see the
sectionLinking for details.

For MSSQLServer or Database Manager on Windows, the parameters REQ and
ALL to the SQLPRE directive are synonyms of each other.

AIX              On AIX, the SQLPRE Compiler directive is not required
                 and has no effect.

Windows          Notes: 

                 The compile process on Windows for IBM DBM was slightly
                 different in previous releases of this COBOL system.  It
                 has now been made compatible with OS/2, ensuring that
                 the .int code is portable between the two operating
                 systems.

                 To compile a program for DBM on the Windows client, you
                 must use SQLRP (see later in this section).

Compiler Directives 

This list summarizes the functionality of the Compiler directives for SQL
support.  For full details on the SQL support Compiler Directives,
including their use and dependencies, see the appendix Directives for 
Compiler in your COBOL System Reference.

------------------------------------------------------------------------------------------
|                                                                                        |
| SQL                   Informs the Compiler that the program contains SQL code and      |
|                       specifies which SQL engine is being used.  If any other SQL      |
|                       directive is specified and any IBM database engine is in use,    |
|                       then this directive is optional.                                 |
|                                                                                        |
| SQLACCESS             Specifies whether an access plan is to be created and stored in  |
|                       database.  If it is not, you must create a bind file and bind    |
|                       the application later or on a different machine (see the SQLBIND |
|                       directive and the section Binding later in this chapter).        |
|                                                                                        |
| SQLBIND               Specifies whether a bind file is required and what it should be  |
|                       called.                                                          |
|                                                                                        |
| SQLBLOCK              Specifies the required blocking mode.                            |
|                                                                                        |
| SQLCOMMIT             Specifies the granularity of automatically generated COMMITS.    |
|                                                                                        |
| SQLCTRACE             Causes the Compiler listing file (if created) to contain details |
|                       of all calls to precompiler services,, used for diagnostics.     |
|                                                                                        |
| SQLDB                 Specifies the name of the database that the program accesses.    |
|                                                                                        |
| SQLDB2                Enables certain DB2 compatibility extensions.                    |
|                                                                                        |

| SQLECSPP              Enables certain DB2 compatibility extensions provided only in    |
|                       conjunction with the add-on product Micro Focus Host             |
|                       Compatibility Option.                                            |
|                                                                                        |
| SQLFORMAT             Specifies the format of date and time fields.                    |
|                                                                                        |
| SQLINIT               Specifies whether automatic connection to the database specified |
|                       in the SQLDB directive is required at run time.                  |
|                                                                                        |
| SQLISOLATION          Specifies the isolation level to use.                            |
|                                                                                        |
| SQLNOT                Specifies the ASCII code of the character used as the NOT        |
|                       character.                                                       |
|                                                                                        |
| SQLPASS               Specifies the user ID and password to be used at compilation     |
|                       time.                                                            |
|                                                                                        |
| SQLPRE                Controls whether a call is to be made to make available SQL      |
|                       support at run time.                                             |
|                                                                                        |
| SQLPROT               Causes the Compiler to provide code to ensure database           |
|                       protection and integrity, if SQLINIT is not used.                |
|                                                                                        |
| SQLRP                 Enables remote compilation on a client.                          |
|                                                                                        |
| SQLSTDLVL             Specifies the standards level of the Database Manager.           |
|                                                                                        |
------------------------------------------------------------------------------------------

Some of the above directives apply to specific database engines only.  In
most cases, the default settings are suitable; the only required
directive being SQLDB.

Compiling Against a Remote Database 

Windows          This section applies only to Windows users who have the
                 add-on product Toolset.  This feature is not available
                 to other users.

You can use the database engine in a client/server environment, where one
or more client workstations access a central database located on a
server.  The client and server can use different operating systems; for
example, a Windows client can access an OS/2 server.  See your database
documentation for further details.

Some client/server combinations enable an application to run on a client
workstation, but the application must have been compiled on the server.
This COBOL system overcomes this limitation.  All compilation-time calls
to the database engine are transferred to the server.  This enables you
to compile the application on the client workstation.  The result is
exactly as if the application had been compiled on the server and all
output files created by the COBOL system copied back to the client
workstation.

To use this facility, you must have a copy of this COBOL system on your
server.  Then do the following:

   *   On the server, enter the command:

     run $cobdir\sqlrps

   *   On the client, specify the SQLRP Compiler directive.  See the
       appendix Directives for Compiler in your COBOL System Reference 
       for more details.

On both the client and server machines, you might need to change the
default parameters to the modules.  These parameters are specified in the
sqlrp.cfg file which contains the following information:

Parameter              Meaning                                                                                                       

SERVER_ID              Name of the server.

                       This can be any name unique across the network,,
                       not necessarily the network name of the server.
                       The name specified is the name that should be used
                       as the parameter to the SQLRP Compiler directive
                       on the client.

COMM_PROTOCOL          Communication protocol.

                       Change this only if you are familiar with the
                       Common Communications Interface (CCI) available
                       with the add-on product Toolset.  The type of
                       network you are using determines which protocol
                       you should use.

                       SQLRP always communicates between different
                       machines on a network rather than different
                       sessions on a single machine; thus for OS/2 the
                       CCINAMP protocol is not supported.  Use the
                       protocol appropriate for your network such as
                       CCINETB or CCIIPX.

DATABASE_ENGINE        The database engine to use.

                       The values that can be specified here are as for
                       the SQL Compiler directive.  See the appendix
                       Directives for Compiler in your COBOL System 
                       Reference for more details of this directive.

TIMEOUT                The time, in seconds, that the server waits
                       between requests from the client or the client
                       waits for a response from the server.

                       If this time is exceeded,, the server or client
                       assumes that the compilation has terminated
                       abnormally and abandons the connection.

TRACE_LEVEL            The level of information produced by the module.

                       These are:

                       0       Error only

                       1       Important messages, such as "waiting for
                               connection"

                       2       Maximum level, used for diagnostics.

Only COMM_PROTOCOL, TIMEOUT and TRACE_LEVEL are specified on the client.

SQLRPS only responds to one client at a time.  If other clients try to
connect while one is already compiling an SQL program, they are forced to
wait.

You can shut down the server from either a client machine or the server.
To do so, enter the command:

     run $cobdir\sqlclose server-id 

where:

server-id           is the name of the server as specified in the
                    configuration file sqlrp.cfg.



MPE/iX 5.0 Documentation