WRITEV, WRITEVU |
![]() ![]() ![]() |
The WRITEV statement writes a specific field to a record of a previously opened file. The WRITEVU statement is identical but preserves any lock on the record.
Format
WRITEV var TO file.var, record.id, field.expr {ON ERROR statement(s)}
where
The keyword ON may be used in place of TO.
The contents of var are written to field field.expr of record record.id of the file. If the record does not already exist, it will be created by this operation.. The WRITEV statement releases any read or update lock on this record. The WRITEVU statement preserves the lock. Within a transaction, the lock is retained until the transaction terminates and then released regardless of which statement is used. Attempting to write a record in a transaction will fail if the process does not hold an update lock on the record or the file.
A field.expr value of zero is treated as a reference to field one. A negative field number causes the var string to be appended as a new field at the end of the record.
The ON ERROR clause is executed for serious fault conditions such as errors in a file's internal control structures. The STATUS() function will return an error number. If no ON ERROR clause is present, an abort would occur.
Example
WRITEV ITEM TO STOCK, ITEM.ID, 3
This program fragment writes the value of ITEM to field 3 of record ITEM.ID in a file previously opened to file variable STOCK. |