Chapter 5: Database Calls

This chapter describes APS database calls.


Coding Calls

Observe the following when coding database calls:


IDMS DB

DB-BIND

DB-CLOSE

DB-CLOSE ALL

DB-ERASE

DB-ERASE REC recordname [PERM|SELECT|ALL]

DB-GET

DB-GET REC [recordname]

DB-MODIFY

DB-MODIFY REC recordname

DB-OBTAIN

DB-OPEN

DB-OPEN [ALL] [MODE usagemode] [AREA areaname]

DB-PROCESS

DB-PROCESS [REF recordname] REC recordname
... [DB-PROCESS-ID name]
... [WHERE keyname operator value]
... [SET setname|AREA areaname] [RESET]
... [HOLD] [EXCLUSIVE]
        Controlled logic block

DB-STORE

DB-STORE REC recordname

Error Handling Flags

Use the following 88-level flags for error handling after executing an IDMS call:

Flag
Status Code
Explanation

AB-ON-REC

0001 through 0306
0308
through 0325
0327
through 0625
1206
through 9999

Any error other than those listed.

DUP-ON-REC

0705 0805,1205

Duplicate key.

END-ON-REC

0307

End of set, area, or index reached.

NTF-ON-REC

0326 0626

Record not found.

OK-ON-REC

0000

Successful operation.

POS-ON-REC

All values of AB-ON-REC whose last 2 bytes are:
06 13

Positioning error.

VIO-ON-REC

All values of AB-ON-REC whose last 2 bytes are:
01 02 08 09 10 14 15 23 31

An update would violate rules.

IDM-COMMIT

IDM-COMMIT [ALL]

IDM-CONNECT

IDM-CONNECT REC [recordname] TO setname

IDM-DISCONNECT

IDM-DISONNECT REC [recordname] FROM setname

IDM-IF

IDM-IF SET setname [EMPTY|NOT EMPTY]
... [MEMBER|NOT MEMBER] paragraphname

IDM-PROTOCOL

-KYWD-  12--*--20---*----30----*---40---*----
 SYEN   IDM-PROTCOL programmode location

IDM-RETURN

IDM-RETURN dataname FROM indexsetname
... [CURRENCY [FIRST|LAST|NEXT|PRIOR]]
... [USING keyfiel] [KEY INTO keyfield]

IDM-ROLLBACK

IDM-ROLLBACK [CONTINUE]

IMS DB

DB-ERASE

DB-MODIFY

DB-MODIFY REC|REF recordname1 [FROM dataarea]
... [VIEW pcbname|PCB pcbname]
  .
  .
... REC|REF recordnameN [FROM dataarea] 
... [VIEW pcbname|PCB pcbname]

DB-OBTAIN

DB-PROCESS

DB-STORE

DB-STORE [REC|REF recordname1] [FROM dataarea]
... [VIEW pcbname|PCB pcbname]
... [WHERE fieldname operator value] [REC|REF recordname2]
... [FROM dataarea] [VIEW pcbname|PCB pcbname]
... [WHERE fieldname operator value] 
... [SUB number] [OF dataarea]
  .
  .
... REC recordnameN [FROM dataarea] 
... [VIEW pcbname|PCB pcbname]
... [WHERE fieldname operator value] [SUB number] [OF dataarea]

Error Handling Fields

IMS provides the following error fields that show how far your call was processed prior to failure:

IM-DB-PCB-SEGLEV

Lowest level in the database for which the requested segment was found.

IM-DB-PCB-SEGNAME

8-character IMS name for the lowest-level segment located.

IM-DB-PCB-KEY-FEED-BACK

Concatenated key information for the path from the root-level to the lowest-level segment found.

IM-DB-PCB-KEY-KFBLEN

Length of data in the IM-DB-PCB-KEY-FEED-BACK field.

Error Handling Flags

Use the following 88-level flags for error handling after executing an IMS DB call:

Flag
Status Code
Explanation

AB-ON-REC

Any not listed below

For any error code not listed below.

DUP-ON-REC

I NI LB

The DB-STORE failed; the new segment would have created a duplicate for a key or sequence field defined as unique.

END-ON-REC

GB

End of database reached.

NTF-ON-REC

GE GB

Requested record not found.

OK-ON-REC

2 spaces, GA GD GK

Everything is OK.

POS-ON-REC

DJ LC LD LE

Positioning error; requested positioning not established.

RTY-ON-REC

GG

Requested record not available. Retry.

VIO-ON-REC

AM DA DX RX IX

An update would violate rules.

Generation Field

IMS provides a field to control program generation:

&IM-SUPPRESS-DB-CALL

Prevent generation of DB calls; set field to YES in APS CNTL file APSDBDC.

GSAM Calls

IM-CLSE view
IM-OPEN view
IM-OPEN-INP view
IM-OPEN-OUT view
IM-OPEN-OUTA view
IM-OPEN-OUTM view
IM-GN pcbname [ssa1 [...ssa15]]
IM-GU pcbname ssa1 [...ssa15]
IM-ISRT pcbname [ssa1 [...ssa15]]

$IM-FLD

$IM-FLD MSDBview fsaname [rootssa]

$IM-FSA

$IM-FSA fsaname segment
... field1[/picture/] operator operand1
... [field2[/picture/] operator operand2]
  .
  .
 ... [field10[/picture/[ operator operand10]]

$IM-POS

$IM-POS DEDBview [SSA]

System Service Calls

IM-CHKP pcbname checkpointID
... [length1 dataarea1 [... length7 dataarea7]]
 
IM-XRST pcbname
... [length1 area1 [... length7 area7]]
... [checkpointID maxiolength]
IM-CHKP-OSVS pcbname checkpointID
IM-DEQ pcbname deqcharacter
IM-GSCD pcbname
IM-LOG pcbname logcode loglength message
IM-ROLB pcbname [msgarea]
IM-ROLL
IM-STAT-DBAS-FULL pcbname
IM-STAT-DBAS-UNFORMATED pcbname
IM-STAT-DBAS-SUMMARY pcbname
IM-STAT-VBAS-FULL pcbname
IM-STAT-VBAS-UNFORMATED pcbname
IM-STAT-VBAS-SUMMARY pcbname

SQL

Built-In Functions

DB-CLOSE

DB-CLOSE CUR[SOR] cursorname

DB-COMMIT

DB-COMMIT [HOLD]

DB-DECLARE

DB-ERASE

DB-FETCH

DB-FETCH CUR[SOR] cursorname [INTO dataname]

DB-MODIFY

DB-MODIFY REC copylibname-REC
... [column1 [(altvalue)] [... columnN [(altvalue)]]]
... [FROM dataname] [WHERE column1 operator [:]altvalue
   .
   .
... AND|OR columnN operator [:]altvalue]
... [END[WHERE]]] [WHERE CURRENT [OF] cursorname]

DB-OBTAIN

DB-OPEN

DB-OPEN CUR[SOR] cursorname

DB-PROCESS

DB-ROLLBACK

DB-ROLLBACK

DB-STORE

Error Handling Flags

Use the following 88-level flags for error handling after executing SQL calls:

Flag
Meaning

AB-ON-REC

Any error not listed in this table.

DB2-DEADLOCK

DB-PROCESS calls check this status to ensure the cursor is not already closed before closing it. SQL closes the cursor if the database is locked.

DUP-ON-REC

DB-STORE failed because the row already exists; duplicates are not allowed.

END-ON-REC

End of table or cursor set reached.

NTF-ON-REC

Requested row not found.

OK-ON-REC

Operation successful.

RI-ON-REC

Referential Integrity check successful (corresponds to SQLCODE -532 to -530).

Error Handling Field

Use the following generated field to indicate whether the associated host variable has been assigned a null value:

01  IND-cursorname|IND-recorename
    05  IND-column

Joins

Special Registers

Use the following special registers in DB-DECLARE, DB-OBTAIN, and DB-PROCESS calls:

CURRENT DATE
CURRENT TIME
CURRENT TIMESTAMP
CURRENT TIMEZONE

UNION


VSAM Batch

DB-CLOSE

DB-ERASE

DB-ERASE REC recordname

DB-MODIFY

DB-MODIFY REC recordname [FROM dataarea]

DB-OBTAIN

DB-OPEN

DB-PROCESS

DB-STORE

DB-STORE REC recordname [FROM dataarea]

Error Handling Flags

Use the following 88-level flags for error handling after executing SQL calls:

Flag
Status Code
Explanation

OK-ON-REC

00

Successful operation.

DUP-ON-REC

02

Duplicate key; duplicates allowed.

END-ON-REC

10

End of file.

INV-ON-REC

20 21 22 23 24

Invalid key condition.

IVD-ON-REC

22

Duplicate key; not allowed.

NTF-ON-REC

23

Record not found.

AB-ON-REC

30 34 90 91 92 93 94 95 96 97

Abnormal condition.

Fields

Use APS-defined data fields and S-COBOL flags in your program.

Name
Associated Calls
Description

APS-END-PROCESS

DB-PROCESS

Flag that terminates a DB-PROCESS loop.

ddname-RRN

DB-OBTAIN
DB-PROCESS
DB-ERASE
DB STORE

Field that controls relative record number (RRN) of a retrieved or stored RRDS file record; generates value for the RELATIVE KEY clause of the SELECT statement.

RESET-OBTAIN

DB-OBTAIN
DB-PROCESS

Flag that resets browse to beginning of file.
Example: TRUE RESET-OBTAIN


VSAM Online

DB-ERASE

DB-FREE

DB-FREE REC recordname|ALL [VIEW keyname] [ENDBR] [UNLOCK]
... [REQID number] [SYSID systemname] [DDN ddname]

DB-MODIFY

DB-MODIFY REC recordname [FROM dataarea]
... [SYSID systemname] [DDN ddname]

DB-OBTAIN

DB-PROCESS

DB-STORE

DB-STORE REC recname [FROM dataarea] [SYSID systemname] [DDN ddname]

Error Handling Flags

Use the following 88-level flags for error handling after executing VSAM online calls:

VSAM Flag
EIBRCODE Flag
ISI-Errors/
ExceptioDnal Condition
Explanation

AB-ON-REC

DSIDERR
ILLOGIC
IOERR
LENGERR
NOSPACE
NOTOPEN
SYSIDERR

DSIDERR
ILLOGIC
IOERR
LENGERR
NOSPACE
NOTOPEN
SYSIDERR

Abnormal condition.

DUP-ON-REC

DUPKEY

DUPKEY

Duplicate key; allowed.

END-ON-REC

ENDFILE

ENDFILE

End of file.

INV-ON-REC

NOTFND
DUPREC

NOTFND
DUPREC

Invalid key condition.

IRQ-ON-REC

INVREQ

INVREQ

Invalid request.

IVD-ON-REC

DUPREC

DUPREC

Duplicate key; not allowed.

NTF-ON-REC

NOTFND

NOTFND

Record not found.

OK-ON-REC

N/A

N/A

Successful operation.

Fields

Use APS-defined data fields and S-COBOL flags in your program.

Name
Associated Calls
Description

APS-shortrecname-VAR

DB-OBTAIN
DB-STORE
DB-MODIFY
DB-PROCESS
DB-ERASE

Field that contains actual record length after a successful record retrieval (direct or sequential for DB-OBTAIN and DB-PROCESS). Supplies value to dataarea in CICS LENGTH option.

Shortrecname comes from the subschema definition; it is the REC card SHORT keyword.

APS-END-PROCESS

DB-PROCESS

Flag that terminates DB-PROCESS loop.

APS-VSAM-NUMREC

DB-ERASE

Field that contains number of records deleted after key-qualified ERASE with partial key length specified.

ddname-APS-KEYnumber

DB-OBTAIN
DB-PROCESS

Field that contains APS-generated key name for use in skip-sequential processing. Ddname is the subschema file.

ddname-RBA

DB-OBTAIN
DB-PROCESS
DB-STORE

Field that contains relative byte address (RBA) of a retrieved, stored ESDS file record; supplies value to CICS RIDFLD option.

ddname-RRN

DB-OBTAIN
DB-PROCESS
DB-STORE

Field that contains relative record number (RRN) of a retrieved or stored RRDS file record; supplies value to CICS RIDFLD option.

RESET-OBTAIN

DB-OBTAIN
DB-PROCESS

Flag that resets browse to beginning of file. When used with PREV, resets to end of file.


Copyright © 2002 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.