820-UPDATERNG-<Index>

Name

820-UPDATERNG-<Index>

Description

This API updates specified fields of the records that match the key and filter conditions, using specified actions and values. Use this API for updates that do not require the original value of a field to be read into the program. For example, to add $20 to an account, the amount originally in the account need not be known.

A return field indicates whether any rows were updated. Also, an error code is returned. Attempts to update a set of rows that cause an error (such as duplicate rows) will cause the update to fail for all of the rows.

Location

The syntax for this routine is generated when a program is compiled.

Input Values

Field Description
<Index> You must specify the index name that will be used to locate the records that will be updated.
Record retrieval variables (also known as DB fields) Define the beginning and ending values of the last key by moving the appropriate values to the record retrieval fields named DB- <KeyFieldName> and DBRNG- <KeyFieldName>.

WS-DB-BEG-RNG

Move the symbolic constant <IndexName>-<IndexFieldName> to the field WS-DB-BEG-RNG in order to tell the interface which key is the last significant one defining the range. The symbolic constant is numerically equivalent to the position of the named field in the Index.

WS-DB-UPDATE-CMD

You must specify the update string that will be used in updating the records.

Note: The same working storage value can be used as the update value for more than one field. This is equivalent to using a MOVE or ADD function with the same value on multiple fields.

Return Values

Field Description
WS-DB-UPDATE-COUNT The working storage field that returns 1 or 0 depending on whether any records were updated.

Using the API in a Program

  • The 820-UPDATERNG-<Index> routine can only be called from within a program transaction.

  • The 820-UPDATERNG-<Index> routine locks the record(s), so there is no need to use a 840-FIND-<Index> or similar routine before performing the update.

  • 820-UPDATERNG-<Index> does not have a subrange equivalent. To restrict the records beyond the range keys, you can use 820-FILTER-UPDRNG-<Index> , as described in 820-FILTER-UPDRNG-<Index>.

Programming Example

          PERFORM
            VARYING I8 FROM 1 BY 1
            UNTIL  (I8 > WS-U-TRD-TABLE-SIZE)
            OR     (WS-U-TRD-TIME-SEQ (I8) = ZEROES)

            STRING
               "STATUS = '4', CHECK-ID = '" DELIMITED BY SIZE
               WS-U-TRD-CHECK-ID (I8)       DELIMITED BY SIZE
               "'"                          DELIMITED BY SIZE
               INTO WS-DB-UPDATE-CMD
            MOVE WS-CURRENT-EMPLOYEE    TO DB-EMPLOYEE
            MOVE WS-U-TRD-TIME-SEQ (I8) TO DB-TIME-SEQ
            MOVE TRDSET1-TIME-SEQ       TO WS-DB-BEG-RNG

            PERFORM 820-UPDATERNG-TRDSET1
          END-PERFORM