DBUpdate

Use this procedure/function to update the database table record which satisfies the key criteria.

Syntax

DBUpdate (Table, Variable, KeyName1, KeyValue1, KeyName2, KeyValue2,...)

Parameter

Description

Table

Enter the name of an open table.

Variable

Enter the name of the stem variable that contains the new information. This variable must first be filled by DBFind, DBFirstRec, or DBNextRec, after which you can modify individual fields before calling DBUpdate.

The default is Table.

KeyName, KeyValue, ...

Each KeyName is the name of a column to search. For some database handlers, it may be case-sensitive.

Each KeyValue is the value of the corresponding KeyName for which to search. For some database handlers, this may be a case-sensitive comparison.

At least one KeyName/KeyValue pair is required.

The system optionally returns one (1) on success or zero (0) on failure.

The actual variable names appended with a prefix are taken from the DFD file associated with the table you specified in the Table parameter or using the column names found in the table if there is no DFD file associated with the table.

This procedure supports a variable number of parameters. As many KeyName and KeyValue pair combinations required to identify the specific keyed record to retrieve and update may be defined as parameters.

If the record cannot be retrieved and updated, possible causes include:

Note Since an ASCII file is not a database, it has no ability to have keys. Therefore, you cannot use this function if the MODE is set to "ASCII."

Example

Here is an example:

Procedure

Result

Explanation

DBFirstRec("APPIDX","RECORD");

 

RECORD.RUNDATE =

DATE();

 

DBUpdate("APPIDX", "RECORD","UNIQUE_ID",RECORD.UNIQUE_ID)

1 or 0

First retrieve the first record from the APPIDX table into the variable named RECORD.

Next change the Rundate (assuming that this column is present in the table) to the current date, and update all records whose UNIQUE_ID field matches that in the variable RECORD (assuming that UNIQUE_ID is truly unique, it will update only the first record in the table).

See also