10.14.15 Update a Record (UPDATE)

Syntax

UPDATE [IN] fname ;

Fname is an internal file name declared earlier.

Purpose

UPDATE is used to change the contents of a data record in the file fname. The new contents of the data record will be the values of the declared fields at the time the UPDATE statement is executed. Any fields in the data file not declared in the FIELDS declaration will remain unchanged in the data record. Any errors that occurred during the update may be found by calling the ERROR function.

Example:

/* Increase subscription rates by 12% */

FOR EACH mag BEGIN

year_rate :=

ROUND (year_rate * 1.12);

UPDATE mag;

IF ERROR (mag) THEN

PRINT "Update failed on ",

title,

" magazine.", NL;

END

Notes

A report program that includes this statement causes the referenced file to be locked when the report begins. The file stays locked until the report completes.