update()
This function executes an update statement a on database b. You can use placeholders in the update statement that are filled with values from list c. Details can be found in the example below.
The function returns the number of changed database table rows. If d is "true", the return value is "-1" in case of an SQL error.
Parameters
Parameter |
Description |
a |
The update statement. |
b |
The database alias. |
c |
The name of the list. |
d |
(optional) If "true", SQL errors coming from the database are ignored. Default: "false". |
Example
We use the following function chain. First, we fill a list with the update parameters and then use them in the placeholders of the update statement.
add to list(a,b,c)
a Value: 12463,file_test.csv
b Value: updatelist
c Value: ,
update (sql-stmt a, alias b, list c, ignore error d)
a Value: update dw_log set file_name=@2:s@ where dw_job=@1:l@
b Value: hub
c Value: updatelist
d Value:
The executed update statement here is update dw_log set file_name='file_test.csv' where dw_job=12463
The syntax for the parameters is @parameternumber:parametertype@. The parameter number is the position of a value in the list and the parameter type s stands for String and I for Integer. For details about the data types, see the documentation of class DefaultSQLCron.