2.2 KiB
ormAccessInsert()
The ormAccessInsert() command inserts a new record into a database table using the provided values for the fields. This command defines the fields and their corresponding values, and stores the result of the operation in a target variable.
Parameters
- fields Type:
variableDescription: A string containing the names of the fields into which the values will be inserted. The field names should be separated by commas. - fieldsValuesVariables Type:
variableDescription: A string containing the names of the variables that hold the values to be inserted into the specified fields. The variable names should be separated by commas, in the same order as the fields infields. - dbase Type:
variableDescription: The name of the database where the table into which the new record should be inserted is located. It must be a variable containing the name of the database. - varTarget Type:
variableDescription: The variable in which the result of the insertion operation will be stored. It must be a variable that will receive a value indicating whether the insertion was successful or not.
Command Flow
Example Usage
Suppose you want to insert a new record into a table called users in a database called myDatabase , with values for username and age coming from the variables newUsername and newAge .
// Define variables
fields = "username,age"
fieldsValuesVariables = "newUsername,newAge"
dbase = "myDatabase"
insertSuccess = ''
// Define the variables with the new values
newUsername = "Alice"
newAge = 31
// Call the command to insert the new record
ormAccessInsert(fields, fieldsValuesVariables, dbase, insertSuccess)
// Return the result of the insertion via addResult
addResult(insertSuccess)
In this example, the ormAccessInsert() command will insert a new record into the myDatabase database in the users table. The values for username and age are provided by the newUsername and newAge variables. The insertSuccess variable will store the result of the operation (whether it was successful or not), and this variable will be returned via addResult(insertSuccess) . The output will reflect whether the insertion was successful ( True ) or failed ( False ).