20. Writing 4GL Statements : Database Access Statements : Using Update to Change a Database Row
 
Share this page                  
Using Update to Change a Database Row
The update statement lets you update the values of columns in a database table using values from fields or simple variables, based on the conditions specified in the where clause. The values can come from simple fields, table field columns, or local or global variables. For example, the following statement updates any row in the personnel table with a value in the idnum column equal to the value in the idnum field on the current form.
update personnel 
  set salary = :sal, manager = :manager 
  where idnum = :idnum;
In the update statement, prefix field names in the current form with a colon to eliminate any possible conflict between the names of fields and database columns. For additional information about runtime substitution in expressions and 4GL names, see "."
Updating a database table from a table field generally involves using the update statement along with the unloadtable statement, as described in Processing an Entire Table Field or Array with Unloadtable and unloadtable Statement--Loop Through Rows and Execute Statements.