next up previous
Next: DISASSEMBLE disassembles assembled messages Up: INSTRUCTIONS Previous: CREATE creates a message

DBUPDATE updates a DBASE IV table

Syntax:

    DBUPDATE(<source table>, <destination table>, <list of fields>);
This instruction is used to update a DBASE IV table (<destination table>) with the values of fields that were previously loaded in an array from another table (<source table>). Both tables must have the same structure. Eventually they may be the same table.
Most frequently DBUPDATE is used in this case: fields of a table are imported, by means of a LOAD instruction, into arrays in the running program, these arrays are changed by the simulation process. Then the new values may be returned, by means of the DBUPDATE instruction, to the same table or to another table that may be void or filled with any number of records. The <list of fields> indicates what fields have to be updated into the <destination table>.
After the execution of the DBUPDATE, the <destination table> remains with the same number of records than the <source table>. See declaration DBTABLE (2.8) and instruction LOAD (6.14).

UPDATE can be used in any type of node.

Example:

  LOAD(Student1, Name, Identif, Age, Year, Score);
  ---------------------------------------
  FOR J := 1 TO N_Student1 DO Student1.Age[J] := Student1.Age[J]+1;
  ---------------------------------------
  DBUPDATE(Student1, Student2, Age, Year, Score);
  ---------------------------------------
  DECL
   DBTABLES (\MainFiles\Student1, \NewFiles\Student2);
The fields Age, Year, Score of the DBASE table Student1 are charged in the running program through the LOAD instruction into the arrays Student1.Name, Student1.Identif, etc. They may be changed by the program. An example of the change of age is shown. After the changes are made, the values are written by means of the DBUPDATE instruction into the corresponding fields of the table Student2. The other fields of the table Student2 remain unchanged. The variables N_Student1, Student1.Age and similar variables for the other fields are introduced automatically by the system with the information taken from the declared DBASE IV tables. They may be managed by the programmer as arrays with index corresponding to the record number. Note that the two files may be in different directories. See example in section 2.8.



domingo c
Mon Mar 20 17:36:19 PST 2000