Features of the DB2 interface
Here
are some of the features of the ULTIM language that apply to the processing of DB2 databases. Some are shown in the example below.
- Ability to automatically convert parts or the whole DB2 dictionary into an ULTIM dictionary.
- Selection of the elements to be processed using either the existing dictionary or a SELECT clause in the program.
- Run-time selection of the subsystem through the ULTIM control file.
- Automatic management of the link protocols to the databases.
- Access to the return code of the coded or generated SQL statement.
Example of dictionary coded in ULTIM, with some fields definitions in COBOL
./*
Information about the divisions
./ DB2 DIVISION, TDIV, 30 ./ ELEMENTS VAL,SECT D-VAL (1,A,10) D-SECT (11,A,7)
./* Basic customer information
./ DB2 CUSTOMER, TCLI, 30 ./ ELEMENTS NO, SECT, DUE, LPAY
ACCOUNT-NBR
(1, N, 7) DIV
(8, A, 6)
BALANCE (14, N, 8.2, 10,
@ED:$) LAST-PAYMENT (22, N,
8, 10, @ED:@DATE)
./* Name and address of the customer ./ DB2 NAMEADDR , TNAM , 105 ./ ELEMENTS NAME, ADD1, ADD2, CODE
./ COBOL
./ COPY PDSDESC (CUSTNAME)
./* COBOL fields from CUSTNAME translated into ULTIM
* NAME (1,A,15) * ADDR-1 (16,A,30) * ADDR-2 (46,A,30) * CODE (76,N,7)
Example
of
program
BEGIN
DEMO.
DEFINE VALUE (P, 5.2, 10,
@ED:$).
* Reading of the data
PROCESS
EACH CUSTOMER WHERE LAST-PAYMENT < 20150301 AND BALANCE > 0.
PROCESS GET @DB2:VALUE WHOSE ; Set VALUE to the VAL element
(SELECT VAL FROM DIVISION ; in the DIVISION table where
WHERE SECT =
:DIV). ; SECT = DIV of the customer
CRITERIA VALUE < 125000.
; Process if the value is lower than 125000
PROCESS GET NAMEADDR
; Get the table TNAM whose CODE
WHOSE (CODE = :ACCOUNT-NRB). ; corresponds to ACCOUNT-NBR of
; CUSTOMER
* Report to be produced
OPTIONS
HEADING=AUTO, SPACING = 5.
REPORT
CUSTOMER:DIV('DIVISION'), NAMEADDR:NAME, ACCOUNT-NBR, BALANCE(12,TOTAL), LAST-PAYMENT.
TITLE ACCOUNTS OUTSTANDING FOR MORE THAN 2 MONTHS AS OF MAY 1, 2015
CONTROL
SUBTOTALS=1.
END
Tabulated report produced by REPORT, TITLE and CONTROL statements
MAY 6, 2015 PAGE 1
ACCOUNTS OUTSTANDING FOR MORE THAN 2 MONTHS AS OF MAY
1, 2015
DIVISION ------NAME----- ACCOUNT
NBR BALANCE LAST PAYMENT
N-EAST LLOYD &
SONS
2369108
$34.94 2015/02/21
THE LAMP
SHOP
3246538
$199.00 2014/12/15
THE
LIGHTHOUSE
1071638
$2,189.10 2015/01/06
........................................... $2,423.04
N-WEST MVC
INC.
1387
$4,189.95 2015/01/28
PLANT
LIGHTING
9066489
$1,450.49 2015/02/12
QUALITY
SWITCH
9193257
$469.20 2015/02/16
ZEUSS
DISCOUNT
1479380
$964.99 2015/02/01
ZIGGER'S
2102981
$2,849.59 2014/11/01
........................................... $9,924.22
S-EAST ACME LITE
LTD.
843896
$360.47 2015/02/11
ELECTRIC
SHOP
2225751
$194.90 2014/12/21
LIGHTNING
LAMP
3178456
$475.20 2014/12/05
RUSSELL &
SONS 386660
$895.45 2015/01/12
TOP
SERVICES
3143486
$10.00 2015/02/01
........................................... $1,936.02 ........................................... $14,283.28
|