| Directives |
|
| Format | WRITE
RECORD (chan[,fileopt])contents$
|
|||||||||||||||||||||||||||||
| Description | Use
the WRITE RECORD directive to add /
update a record for a file (logical file number /
channel). If the specific record already exists (indexed,
direct, or sort files) and you include the DOM=stmtref
option, control transfers to the stmtref.
Otherwise, the specified record is updated. In Keyed files with multiple keys, the WRITE RECORD directive automatically updates all alternate keys. ProvideX supports use of the WRITE RECORD directive with *MEMORY*. Automatic Padding with KEY=Option When you use KEY=string$:string$[:string$][...] ProvideX automatically pads key segments. This is valid only if you have Keyed files with segmented key definitions. ProvideX right-pads the key segment using $00$ (nulls) to the segment's full length. The last segment in a compound key is not padded; e.g.,
is the same as
A WRITE operation will check the last entry in the key table for the key being added before proceeding to the top of the key chain to determine the new entry point. This dramatically increases the speed of writing additional records in sequential order. You can use WRITE and/or WRITE RECORD directives to update records in a Memory file using an IOList or a string expression. You can add records by index, inserting records at the given index number. ProvideX will not overwrite existing records. Use the DOM= option when you write to a Memory file. The following two examples below insert a new record at index 3 without overwriting the current record at index 3. The record that was at index 3 is now at index 4 and the number of records in the file has increased by one.
To update a given record in a Memory file, use KEY= with a given key value:
|
|||||||||||||||||||||||||||||
| Example | 0010
OPEN (1)"OLDFIL" 0020 OPEN LOCK (2)"NEWFIL" 0030 READ RECORD (1,END=1000)R$ 0040 WRITE RECORD (2)R$ 0050 GOTO 0030 1000 CLOSE 1010 END |
|||||||||||||||||||||||||||||
| See Also | WRITE
Add/Update Data in File INSERT Insert New Record in File UPDATE Update Existing Record in File |
|||||||||||||||||||||||||||||