|Interface to Oracle DBMS||File Structures|
This chapter describes how to use Sybase in this COBOL system and how to compile and link COBOL programs containing their code. It also describes the COBOL to Sybase integration package, explaining how to use it.
You can access the SQL functions offered by the database system from your COBOL program by embedding SQL statements in your COBOL programs using the following format:
EXEC SQL SQL_statement END-EXEC.
A preprocess step then replaces statements of the above form with the relevant calls to database services. Other additions are made to the source code to bind host COBOL variables to the SQL variable names known to the database system.
The advantage of embedding SQL in this way is that the programmer need not know the format of individual database routines. The disadvantage is that the resulting source code must be linked to the database routines, and therefore Animator using .int and .gnt code variants are unavailable. The COBOL to Sybase integration package described later in this chapter overcomes this limitation, but the source code used by Animator is the output from the precompiler rather than the original Embedded SQL written by the programmer. This disadvantage can be overcome by using the COBSQL integrated preprocessor (see the chapter Using COBSQL).
Please consult on disk documentation for information about the compatibility of this COBOL System with the various database management systems and their precompilers.
You can run your COBOL program containing Sybase code in .int or .gnt code format. To make Sybase calls accessible to COBOL programs in .int or .gnt code format, you must use the syblib interface module to resolve the calls from COBOL to Sybase.
The COBOL to Sybase integration package, consists of:
|syblib.gnt||main integration library|
|syblib.cbl||source code for syblib|
syblib simply loads the appropriate Sybase DLL. The source code is supplied in case Sybase change their DLL names in a future release.
For Windows the Sybase DLL is called wcobct.dll
16 bit OS/2 applications are not supported.
For 32 bit OS/2 applications the name is cobct.dll.
You also need the Open Client Embedded SQL/Cobol support files and Open Client or a local database. See the documentation supplied with your Sybase product for details on the support files required.
On UNIX you can animate and run .int and .gnt code by using a COBOL run-time system that has been linked with the SQL run-time routines supplied by Sybase.
You should use the makefile supplied by Sybase to rebuild the COBOL run-time system to include Sybase support.
Linking COBOL programs containing Sybase code is described in the manuals supplied with Open Client Embedded SQL/COBOL by Sybase.
You can load a COBOL to Sybase Interface Module in any of the following ways:
This is the simplest way. This call must be made before any database access is attempted.
This Compiler directive forces the main module to automatically load the specified module.
With a built system, the application has a configuration (.cfg) file that specifies the programs that makeup the system. You can modify this .cfg file to preload the syblib module as the system is started.
See the section Using COBOL Configuration Files for further details on this method.
Note: If you use either of the first two methods, ensure that only the top-level program calls the syblib interface module. Do not compile a subprogram with the INITCALL directive.
If you are using the Build utility, you can load your syblib file from your application configuration file. To do so, you must add the following information to your .cfg file:
[APPLIC-STARTUP] APPLICATION-LIBRARY:applic.lbr INITIALIZATION-LIBRARY:TOOLS.LBR
[APPLIC-PROGRAMS] applic.lbr UTILS.LBR
applic.lbr is a user-defined name
for the user application library file.
Sybase uses .pco and .cbl filename extensions. For the Micro Focus Copybook Preprocessor (CP) to resolve copybooks and include statements correctly, use the following COBOL Compiler directives:
You can use Workbench Organizer to create a Sybase project (see the chapter Configuring Your Organizer Desktop in your Workbench User Guide). Typical values are:
|Project name:||Sybase Demos|
|Directives:||osext(eco) p(cobsql) p(cp) sy|
If you are using COBSQL you can use the cobsql.dir file to specify COBSQL directives. Typical values are shown below:
confirm cbl2syb cobsqltype=sybase cobsqlinclude=e:sql10\include end-c -m
If you are using COBSQL in conjunction with the Sybase precompiler, you should bear in mind the following points.
For example, if the OS/2 client is causing problems and locales.dat contains the following settings for OS/2:
locale = default, us_english, iso_1 locale = enu, us_english, iso_1 locale = fra, french, iso_1 locale = deu, german, iso_1
then the LANG setting for English would be:
SYB error-no error-type error-text
where the parameters are:
||A string that COBSQL uses to identify a modified Sybase error message.|
||An error number assigned to the Sybase Error. This is used to uniquely identify each error message.|
||Indicates the severity of the error. Some of the Sybase messages are only warnings rather than normal or fatal errors.|
||The original Sybase error message.|
Only the English version of esql.loc has been modified, but other language versions can also be modified. We recommend that you make a copy of the esql.loc file before altering it. Using the modified version of esql.loc, COBSQL can detect the full range of Sybase error messages.
The location of esql.loc is dependent on the language and code page used. This is defined in the locales.dat file. If the definition of the default language for the AIX platform is:
locale = C, us_english, iso_1 locale = En_US, us_english, iso_1 locale = en_US, us_english, iso_1 locale = default, us_english, iso_1
the default langauge would be us_english, using the iso_1 code page. This means that the copy of esql.loc to be used is:
where Sybase-home is the Sybase installation directory.
For more information on how Sybase uses and locates the different error message files, refer to your Sybase documentation.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
|Interface to Oracle DBMS||File Structures|