Table of Contents
Updates the values of one or several table fields at the chosen records.
update_statement_searched : UPDATE table_name SET set_clause [ , set_clause ... ] [ WHERE search_condition ] set_clause : column_name = < DEFAULT | NULL | expr >
The WHERE statement chooses the records which are to be updated. If WHERE is not defined, all the table records will be updated.
SET operator defines which fields could be updated and defines new values for them, and is the operation list of the assignment statements which are separated by a comma from one another. In each statement, the object field which is updated is identifying and new value for this field is defined. Each object field should be mentioned in the list only once; also it shouldn’t be to assignment statements for the same object field.
UPDATE tbl1 SET fldLong = 1100 WHERE fldLong > 1000
UPDATE command supports SQL binding of parameters. It means that together with the query programmer sends the array of the records with the value representation. From the array, you can refer with the help of the index using the syntax: :N.
Some advantages of linkage usage:
- you don’t waste CPU time for the unprintable characters’ allocation inside the string (escape quotes);.
- you don’t waste CPU time for the building of string query using concatenation, instead you get the fixed query form and just update the values in the linked array.
- SQL parser gets a string query in shorter form and thus spends less CPU time for the analyze.
- you can link BLOB values AS IS.
Example: of parameters binding
stmt = db.CreateStatement( "UPDATE person SET name = :1, f2 = :2" ) stmt.Bind_string( "john" ) stmt.Bind_null() stmt.SqlExecute()