Function
This instruction is used to update the values of the records retrieved from the table mapped by a
DB_CreateMapping instruction according to the retrieval conditions specified in the Where input variable
(WHERE clause) with the values of a DB Map Variable specified in the MapVar input variable.
The records to update are retrieved according to the retrieval conditions specified in the Where input variable
(WHERE clause). The Where input variable is expressed as a text string.
The text string in the Where input variable cannot consist of NULL characters (16#00) only. In that case, the
instruction is terminated due to an error.
When using single quotes in the WHERE clause, use the escape character ($’).
Refer to the NJ/NX-series CPU Unit Software User’s Manual (Cat. No. W501) for the escape character.
Refer to the manual of the database for the format of the WHERE clause.
Specify the retrieval conditions by the following values in the Where input variable.
Example 1: Update the values of the records where the value of a specific column is equal to or greater than
the specified value.
Update the values of records where the value of “ColumnA” (unsigned integer) is 1234 or greater.
'“ColumnA” >= 1234'
SQL statement to create: UPDATE TableProduct SET “ColumnA” =<value>, “ColumnB” =<value> Where
“ColumnA” >= 1234
Example 2: Update the values of the records where the value of a specific column starts with the specified text
string.
Update the values of records where the value of “ColumnB” (text string) starts with ‘ABC’.
'“ColumnB” LIKE $'ABC%$''
SQL statement to create: UPDATE TableProduct SET “ColumnA” =<value>, “ColumnB” =<value> Where
“ColumnB” LIKE 'ABC%'
Example 3: Update the values of the records where the value of a specific column is equal to or greater than
the value of the specified variable.
Update the values of records where the value of “ColumnA” (unsigned integer) is equal to or greater than the
specified variable.
Specified value: UINTVar := 1234;
Input parameter in the WHERE clause:
WhereCond_Update := CONCAT(‘$”ColumnA$” >= ‘, UINT_TO_STRING(UINTVar));
SQL statement to create:
UPDATE TableProduct SET “ColumnA” =<Value>, “ColumnB” =<Value> Where “ColumnA” >= 1234
When the Spool function is enabled, the SQL statement is stored in the Spool memory in the following cases. In
these cases, _DBC_SEND_SPOOLED is set in the SendStatus output variable and the instruction is terminated
due to an error.
When the DB records cannot be updated due to a network failure or other causes (DB Connection
Disconnected Error Status)
When the DB records cannot be updated within the time specified in the TimeOut input variable (DB
Connection Instruction Execution Timeout)