Table of Contents
UPDATE
Updates the values of one or several table fields at the chosen records.
Syntax
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. It is the operation list of the assignment statements separated by a comma from one another. In each statement, the object field which is updated is identified and a 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.
Example:
UPDATE tbl1 SET fldLong = 1100 WHERE fldLong > 1000
SQL Binding
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 queries using concatenation, instead, you get the fixed query form and update the values in the linked array.
- SQL parser gets a string query in shorter form and thus spends less CPU time for the analysis.
- 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()