assistance-engine/docs/developer.avapframework.com/appendices_20.md

38 lines
2.1 KiB
Markdown

## ormAccessUpdate()
The `ormAccessUpdate()` command updates records in a database table based on the provided selection criteria. This command modifies the values of specified fields in a database using the corresponding values from variables.
### Parameters
* fields Type: variable Description: A string containing the names of the fields to be updated. The field names should be separated by commas.
* fieldsValuesVariables Type: variable Description: A string containing the names of the variables holding the new values for the specified fields. The variable names should be separated by commas, in the same order as the fields in fields .
* dbase Type: variable Description: The name of the database where the table to be updated is located. It should be a variable containing the name of the database.
* selector Type: variable Description: A condition to select the records to be updated. It should be a string specifying the selection criteria in SQL format, such as id = 1 .
* varTarget Type: variable Description: The variable in which the result of the update operation will be stored. It should be a variable that will receive a value indicating whether the update was successful or not.
### Command Flow
### Example Usage
Suppose you want to update the `age` field to 31 for the user with `id` equal to 1 in a database called `myDatabase`.
```javascript
// Define variables
fields = "age"
fieldsValuesVariables = "newAge"
dbase = "myDatabase"
selector = "id = 1"
updateSuccess = ''
// Define the variable holding the new value
newAge = 31
// Call the command to update the record
ormAccessUpdate(fields, fieldsValuesVariables, dbase, selector, updateSuccess)
// Return the result of the update via addResult
addResult(updateSuccess)
```
In this example, the `ormAccessUpdate()` command will update the `age` field in the `myDatabase` database for the record where `id = 1`. The new value for `age` is 31, stored in the `newAge` variable. The `updateSuccess` variable will store the result of the operation (whether it was successful or not), and this variable will be returned via `addResult(updateSuccess)`.