MvUPDATE#
Updates the current database record of NAME db_alias, with the contents of the database fields.
<MvUPDATE NAME = "string: { expression } | literal"
VIEW = "string: { expression } | literal">
When you are working with a database, Miva Script maintains a record pointer to the current record. A record becomes the current record when you navigate to it using <MvFIND>
, <MvGO>
, or <MvSKIP>
. You will need to navigate to the records you want to change before updating.
Attributes#
Attribute | Description |
---|---|
NAME |
Optional database alias. When a database is opened it is referenced in all other database commands by the alias. If omitted, the current record in the primary database is updated. |
VIEW |
Optional odbc_view. Support for ODBC has been dropped so this attribute can be omitted. |
Examples#
Miva Script creates database variables in the form alias.d.fieldname
that correspond to the fields of the current record in each open database, and it is through these variables that your program can read and write the data in the record. In this example, the database is opened with <MvOPEN>
and the desired record is found with <MvFIND>
. Then values are assigned to two variables corresponding to the title and salary fields in the employees database: employees.d.title
is set to 'Director'
and employees.d.salary
is set to '250000'
. Finally <MvUPDATE>
stores these values in the current record, overwriting the previous data.
<MvOPEN NAME="employees" DATABASE="{ g.path $ 'workers.dbf' }" INDEXES="emp_name.mvx">
<MvFIND VALUE="Jeeves">
<MvIF EXPR="{ NOT employees.d.EOF }">
<MvASSIGN NAME="employees.d.title" VALUE="Director">
<MvASSIGN NAME="employees.d.salary" VALUE="250000">
<MvUPDATE>
</MvIF>
<MvCLOSE NAME="employees">
<MvUPDATE>
locks the record that is being updated.