Description

Inserts or updates a row in the table. If the row does not exist, a new one will be created in the table. It the row does exist, it will be overwritten.

Syntax

Write expression on | to filevar, key then | else statements

Parameters

The Write statement has the following parameters.

ParameterDescription
ExpressionEvaluates to the row that is to be written to the table.
FilevarRefers to a table variable that has been opened in a previous Open statement.
KeySpecifies the key of the record to be written.
ThenThe statement(s) following Then are executed if the record is written successfully.
ElseThe statement(s) following Else are executed if the row cannot be written. The Status() function indicates the severity of the error, and the system variable @FILE_ERROR contains detail about the nature of the error.

See also

OpenMatReadMatWriteReadReadVWriteV

Example

/* The program reads row 100 in the CUSTOMER file and writes a value to column 5. */
 
@ID = 100
open "CUSTOMER" To FILE_CUSTOMER then
  read REC From FILE_CUSTOMER, @ID then
    REC<5> = "Stamford"
    Write REC On FILE_CUSTOMER, @ID else
      status = Set_FSError()
    end
  end
end
  • No labels