Skip to content

Creating and Changing Records

Creating New Records

Immediately after an open command, the record buffer is clear. Data moved to the record buffer will create a new record in the table if it is saved. The record buffer is also clear immediately after execution of a clear command on an open table, and again a new record will be created on save.

To create a new record with some of its column data derived from an existing record, move a value (0 is recommended for clarity of intent) to the recnum of the table before the save. The existing record must, of course, first be found and moved into the record buffer.

Editing Existing Records

To change an existing record, the procedure is much simpler. Merely find the desired record, move the changed data into the buffer, and save the changed buffer.

This description omits considerations that are vital to multi-user situations, where more than one user may be modifying the same record at the same time. In such cases, it is essential to reread the record data from the disk immediately before saving to avoid overwriting other users' saved changes with obsolete column data (that you did not change) drawn from the disk before their changes were saved.

It is important to remember that the multi-user features of DataFlex are complete, well-designed, and so easy to use in most situations that they are virtually invisible. For additional information, see Multi-User Considerations.

Saving and Deleting Records

When there is data in the buffer, a saverecord command will save the buffer data either back to the existing record it was drawn from or to a new record. A companion command, save, first fills all columns that relate to columns in parent tables with the data in the companion parent columns, then performs a saverecord. This amounts to an attach followed by a saverecord.

The delete command only operates on the tables named in the command line, never on ancestor or other tables not named. For delete to work, the record buffer must contain an identifiable record—that is, an intact record number. A delete executed against a buffer of which this is not true will generate an error.

See Also