IB Statements/update

From CometWiki

Jump to: navigation, search

UPDATE statement

Syntax: UPDATE (lun, format-statement-label) KEY=index [,EXCP=statement-label | NOEXCP]

Discussion: The UPDATE statement modifies only specified fields in a data record of a file.

The UPDATE statement extracts the specified record (placing it in the user's buffer), moves the field(s) being updated into the correct position(s) in the user's buffer (as specified with a FORMAT statement), and rewrites the data in the directory with an unindexed WRITE statement.

Note: Because the record is temporarily extracted during an UPDATE operation, other programs that access the same file must be prepared for the possibility of encountering an extract exception.

Example: 1000 FORMAT FLAG1$,@(50);FLAG2$,@(100)

.

OPEN (1) "FILEB"

.

FLAG1$ = "NEW"

FLAG2$ = "TEST"

UPDATE (1,1000) KEY=CUSTNUM$

This example shows how to use the UPDATE statement to update several fields in a data record. The FORMAT statement defines the fields to be updated, and their positions in the data record. In the Procedure Division of the program, the data variables are set to their new values, and the UPDATE statement is executed.

Personal tools