Not supported in COBOL2000-BC !
A description of the universal database management system UDS/SQL is given in the UDS/SQL manuals: “Design and Definition” [13], “Creation and Restructuring” [14], and “Application Programming” [15].
UDS/SQL databases are processed by user programs via
COBOL-DML language elements (DML is an integral component of COBOL) and
CALL DML (database handling via subprogram call).
The following text concentrates on COBOL-DML. Furthermore, it is assumed that schema and subschema have already been generated. The individual steps towards generating a UDS/SQL user program are briefly explained.
The Database Handler (DBH), the main component of the UDS/SQL database system, is responsible for communication between the user program and the database (via the subschema). A distinction is made between:
Linked-in DBH: It is linked into the user program and is therefore suitable for cases where only one user program is to work with the database.
Independent DBH: This is not linked into the user program and is therefore capable of controlling more than one user program (independent task).
Structure of a COBOL-DML program
DATA DIVISION. . . . SUB-SCHEMA SECTION. DB subschema-name WITHIN schema-name. PROCEDURE DIVISION. . . Sequence of COBOL-DML statements ... .
The formats of the COBOL-DML statements are described in “Application Programming” manual [15].
schema-name/subschema-name are defined at schema/subschema generation time.
Compiling a COBOL-DML program
The COBOL2000 compiler generates a program module and a subschema module from a COBOL-DML program. When the user program is compiled, the COBOL compiler must read the COSSD file of the database concerned.
The following options are available here:
The COSSD file is assigned explicitly to the COBOL compiler using the command
/ADD-FILE-LINK LINK-NAME=UDSCOSSD, - / FILE-NAME=[:catid:][$userid.]dbname.COSSD
Here
:catid:
and$userid
are the catalog ID and the user ID under which the COSSD file is cataloged. If the:catid:
or$userid
specification is missing, the file name is complemented in accordance with the standard BS2000 rules.The COSSD file must be cataloged under the name specified in the command since in the event of an error no search is made for a COSSD file at a different location. This procedure is mandatory when multiple COSSD files with the corresponding database name exist in all catalogs which can be accessed locally from the user ID.
Example of a command sequence:
/ADD-FILE-LINK UDSCOSSD,dbname.COSSD /START-PROGRAM $COBOL2000 COMOPT MODULE=module-library END compilation-unit-file
The COBOL compiler is notified of the database name using the following command.
/SET-FILE-LINK LINK-NAME=DATABASE, - / FILE-NAME=[:catid:][$userid.]dbname
Any
:catid:
specified in the SET-FILE-LINK command is ignored. The COBOL compiler then searches for a COSSD file with the namedbname.COSSD
in all catalogs which can be accessed locally from the user ID which was specified explicitly in the SET-FILE-LINK command or was complemented by BS2000. This procedure can be used only when just one COSSD file with the corresponding database name exists in the specified catalog environment.Example of a command sequence:
/SET-FILE-LINK DATABASE,dbname /START-PROGRAM $COBOL2000 COMOPT MODULE=module-library END compilation-unit-file
If ADD-FILE-LINK or SET-FILE-LINK commands exist for both LINK=DATABASE and for LINK=UDSCOSSD, only the procedure for LINK=UDSCOSSD is used.
Linking a COBOL-DML program
The link-editing of COBOL programs is described at length in the chapter “Generating and calling executable programs”.
Note that for COBOL-DML programs a suitable UDS/SQL connection module must be linked in, depending on the DBH version used (linked-in/independent). For further information see “Application Programming” manual [15].
Example of a linkage editor run:
/START-BINDER //START-LLM-CREATION INT-NAME=programmname //INCLUDE-MODULES LIB=module-library, ELEM=cobol-dml-programm //INCLUDE-MODULES LIB=uds-module-library, ELEM=uds-connection-modul //RESOLVE-BY-AUTOLINK LIB=$.SYSLNK.CRTE //SAVE-LLM LIB=module-library, ELEM=uds-test-prog //END
Execution of a UDS/SQL user program
When the independent DBH is used, execution of a UDS/SQL user program is possible only within a UDS/SQL session. The connection to this session or to the database is provided by the SET-FILE-LINK command (see the UDS/SQL (BS2000/OSD) manual [15]).
Execution with linked-in DBH:
/SET-FILE-LINK DATABASE,dbname /START-PROGRAM filename [DBH parameters] PP END [user-program-parameters]
Execution with independent DBH:
/SET-FILE-LINK DATABASE,dbname /START-PROGRAM filename [user-program-parameters]