SaveRecord
See Also: Understanding File Buffers and DDO Field Buffers, Attach, Lock, Reread, Save
Purpose
To save changes made to a record buffer to the database on disk without updating fields that relate to other tables with data from those tables. This command is usually not used when working with Data Dictionaries.
Syntax
SaveRecord
table [...table]
table is the logical name or filelist number used to identify the table.
What It Does
SaveRecord saves data in the buffer for table to the disk and updates all indexes. If the record buffer was active (contained an existing record) prior to the SaveRecord, that record is edited. If the record buffer was inactive, a new record is created.
SaveRecord transfers all data in the record buffer to the disk. It does not do an automatic attach.
Example 1
find ge boxcars by 2
If (found) begin
reread boxcars
move sNew_owner to boxcars.owner
saverecord boxcars
unlock
end
In this example, a record in Database File boxcars is found, and the value of a field is changed. Then a SaveRecord writes the changed data back to the table. The record will retain the same record number and all other fields will remain unchanged.
Example 2
clear boxcars
Move sId to item boxcars.id
Move sLocation to boxcars.location
saverecord boxcars
This example starts with a clear (new-record) buffer, fills it with data, and does a SaveRecord. This will create a new record in Database File boxcars, and update all online indexes.
When table relates to one or more parent tables, and data in the field(s) on which such relationship(s) is (are) based may be changed, you must use Save rather than SaveRecord, unless you include an attach with the SaveRecord.
Notes
-
Once you move data to an active record buffer, you must either save that record or deactivate it. Doing otherwise will trigger DataFlex Error 82 (Edited record not saved).
-
If you
SaveRecordwhere no change has been made to the contents of the record buffer, noSaveRecordwill take place. -
In multi-user operations, be sure to issue a
Rereadcommand immediately before moving data to the record buffer and executing theSaveRecord, and unlock as soon thereafter as possible. -
SaveRecordupdates all online indexes, adding or modifying key entries for the saved record. -
When
tablehas parent tables and you wish an attach done, use theSavecommand. -
The capability to name multiple tables in one command is provided as a convenience. The command:
saverecord thisTable thatTableis exactly the same as:
saverecord thisTable saverecord thatTable -
You can pass either the table's logical name or its filelist number to the
SaveRecordcommand.