Previous Topic Next topic Print topic


DB-STORE

The purpose of this call varies depending on the target.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Targets:

  • IMS DB
  • SQL
  • VSAM Batch
  • VSAM Online

IMS DB

DB-STORE enables you to:
  • Specify either a single record level or multiple records along a path, like DB-OBTAIN.
  • Store a dependent segment--one that references one or more parent level segments to specify the exact record placement. This is a compound DB-STORE.
Syntax:
DB-STORE [REC|REF recordname1] [FROM dataarea]
... [VIEW|PCB pcbname]
... [WHERE fieldname operator value]
... [REC|REF recordname2] [FROM dataarea]
... [VIEW|PCB pcbname]
... [WHERE fieldname operator value]
... [SUB number] [OF|IN dataarea]
        .
        .
        .
... REC recordnameN [FROM dataarea]
... [VIEW pcbname|PCB pcbname]
... [WHERE fieldname operator value]
... [SUB number] [OF dataarea]
General Rules:
  1. When a record is not obtained from the default I/O area, such as by DB-OBTAIN INTO, code FROM dataarea.
  2. When a record is not obtained from the default PCB, such as by DB-OBTAIN VIEW|PCB, code VIEW|PCB pcbname.
  3. When you store a new root, DB-STORE places the record according to its key field value. If a STORE for a dependent record provides qualification at each parent level, this qualification specifies the position of the new record. Otherwise, prior database positioning determines record placement. Thus, a DB-STORE for a dependent record should either
    • Specify qualification at each parent level, or
    • Ensure that the preceding database call executed for the database PCB accesses the desired parent.
  4. Use the CCODE keyword to include additional IMS command codes. See the topic IMS command codes for a list of valid CCODEs.
Parameters:

REC|REF recordname

IMS segment to process.

FROM dataarea

Alternate I/O area where program deletes, modifies, or adds a record. Required for a record obtained from an I/O area other than the default I/O area, such as by DB-OBTAIN INTO.

VIEW|PCB pcbname

Synonymous with VIEW. Specify the PCB used when the PSB contains multiple PCBs for the same database.

WHERE keyname operator value

Operator can be =, EQ, >, GT, <, LT, >=, GE, <=, LE, <>, NE, ^=. Value can be literal, data name, or an asterisk (*). An asterisk indicates the segment record description contains the key value.

SUB[SCRIPT] (value)

Move the subscripted field value to a specified field. Value can be a data name, literal, or, under VSAM Batch or Online, an integer.

OF|IN dataarea

Qualify the I/O area moving to the value field, when more than one structure in the Data Division contains the field.

Examples:

Add an occurrence of RECORD-A to the database.

DB-STORE REC RECORD-A

Add one occurrence of RECORD-A and one of its dependents, RECORD-B.

DB-STORE REC RECORD-A REC RECORD-B

Add one occurrence of RECORD-B, a dependent of a specific RECORD-A.

DB-STORE REF RECORD-A WHERE FIELD-1 = VALUE-1
... REC RECORD-B

Alternately, add RECORD-B by coding DB-STORE after DB-OBTAIN.

DB-OBTAIN REF RECORD-A WHERE KEY-A = VALUE-A
DB-STORE RECORD-B

SQL

DB-STORE enables you to add entire rows or selected columns.

Syntax: for Format 1
DB-STORE REC copylibname-REC
... [column1 [(altvalue)] [... columnN [(altvalue)]]]
... [FOR number ROWS] [NOT ATOMIC]
... [FROM dataname]
... [QUERYNO number]
... [WITH [CS|RS|RR]]
Syntax: for Format 2
DB-STORE REC copylibname-REC
... [column1 [(altvalue)] [... columnN [(altvalue)]]]
... [DB-OBTAIN REC copylibname-REC
... column1 [... columnN]
... [FOR number ROWS] [NOT ATOMIC]
... WHERE column1 operator [:]altvalue
... [AND|OR column2 operator [:]altvalue]]
        .
        .
... [AND|OR columnN operator [:]altvalue] ]
... [QUERYNO number]
... [WITH [CS|RS|RR]
Parameters:

REC copylibname-REC

Specify the 01-level name of the COBOL row layout in the DCLGEN or copybook information. Copybook library name of source data. Cannot be the same as any cursor names or DB-PROCESS-ID names.

column1 [(altvalue)]

Altvalue can be a literal, column name, host-variable, or one of the following expressions:

  • GENERATE_UNIQUE()
  • NEXT VALUE FOR sequencename
  • PREVIOUS VALUE FOR sequencename

See also the information on Host variables in the General Rules section of the Help topic Database Calls.

FROM dataname

Move alternate data structure to the host variable structure name. Data moves prior to the actual SQL call via MOVE statement.

FOR number ROWS

Controls how many rows are returned.

NOT ATOMIC

Rows should not be inserted as an atomic operation.

Note: Do not code ATOMIC, which is the default and should not be coded.

WHERE column operator

Column is the column on which to qualify the selection. Operator can be =, ^=, >, <, >=, <=, native SQL predicates (such as LIKE and BETWEEN).

[:]altvalue

Altvalue can be a literal or a data name.

QUERYNO number

Specifies the number to be used for this SQL statement in EXPLAIN output and trace records.

WITH

Specifies the isolation level at which the statement is executed.

CS

Cursor stability

RS

Read stability

RR

Repeatable read

Examples:

Insert specific columns into D2MASTER; for PM_PART_NO, store information from the default COBOL host variable; for other columns, name alternate sources of information.

DB-STORE REC D2TAB-REC
... PM_PART_NO PM_NEW_PART_NO ('23432')
... PM_COLOR (:WS-NEW-COLOR)

Insert columns IN_PART_NO and IN_UNIT_BASE_PRICE from D2MASTER into table D2INVEN; select only rows from D2MASTER where PM_PART_NO does not equal PM_NEW_PART_NO.

 DB-STORE REC D2INVEN-REC
 ... IN_PART_NO IN_UNIT_BASE_PRICE
 ... DB_OBTAIN REC D2MASTER-REC
 ... PM_PART_NO PM_UNIT_BASE_PRICE
 ... WHERE PM_PART_NO not= PM_NEW_PART_NO

Use SQL insert with expressions and with the DEFAULT keyword.

DB-STORE
... REC EMSAVING-REC
... ACCOUNT_NUMBER ('100')
... CUSTOMER_NAME ('MILLER')
... ADDRESS_1 ('101 FIRST STREET')
... ACCOUNT_TYPE (DEFAULT)
... CITY ('JEFFERSON')
... STATE ('NY')
... ZIP_CODE ('19801')
... PREVIOUS_BALANCE (1000 + 22)
... DEPOSITS (1000 / 21.6)
... WITHDRAWALS (1000 / 22.5)
... INTEREST_PAID (1000 - 22)
... CURRENT_BALANCE (WS-CUR-BALANCE * 22)

VSAM Batch

Syntax:
DB-STORE REC recordname [FROM dataarea]
Parameters:

REC|REF recordname

COBOL record to process.

FROM dataarea

Alternate I/O area where program deletes, modifies, or adds a record. Required for a record obtained from an I/O area other than the default I/O area, such as by DB-OBTAIN INTO.

Example:

Write ORDR-RECORD to the file; check file status.

DB-STORE REC ORDR-RECORD
IF OK-ON-REC
    SCREEN-MSG = 'ORDER ADDED TO FILE'
ELSE-IF IVD-ON-REC
    SCREEN-MSG = 'ORDER ALREADY EXISTS'

VSAM Online

Syntax:
DB-STORE REC recordname [FROM dataarea]
... [SYSID systemname] [DDN ddname]
Parameters:

REC recordname

COBOL record to process.

FROM dataarea

Alternate I/O area where program deletes, modifies, or adds a record. Required for a record obtained from an I/O area other than the default I/O area, such as by DB-OBTAIN INTO.

SYSID systemname

Remote system name (maximum 4 characters); can be a literal region name or a Working-Storage field.

DDN ddname

Specify file ddname; can be a literal or data name defined as PIC X(8). Supply a value to the name option of CICS DATASET.

Example:

Write ORDR-RECORD to the file; check file status.

DB-STORE REC ORDR-RECORD
IF OK-ON-REC
    SCREEN-MSG = 'ORDER ADDED TO FILE'
ELSE-IF IVD-ON-REC
    SCREEN-MSG = 'ORDER ALREADY EXISTS'
Previous Topic Next topic Print topic