See Also: Understanding File Buffers and DDO Field Buffers, Attach, Lock, Reread, Save
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.
SaveRecord table [...table]
table is the logical name or filelist number used to identify the table.
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.
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.
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 on line indexes.
Where 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.
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 saverecord where no change has been made to the contents of the record buffer, no saverecord will take place.
In multi user operations, be sure to issue a reread command immediately before moving data to the record buffer and executing the saverecord, and unlock as soon thereafter as possible.
Saverecord updates all on line indexes, adding or modifying key entries for the saved record.
When table has parent tables and you wish an attach done, use the save command.
The capability to name multiple tables in one command is provided as a convenience. The command:
saverecord thisTable thatTable
//is exactly the same as:
saverecord thisTable
saverecord thatTable
You can pass either the table's logical name or its filelist number to the saverecord command.