How You Can Use the Update Statement
The update statement replaces values in specified columns of a database table with new values. These new values can come from any of the following places:
• Variables associated with the current frame
• Columns from another table
• The result of an evaluated expression
• Global variables
• Constants
• A subselect
You can update all the rows in a table. For example, assume that you want to change to five-digit account numbers for customers. The following statement updates all existing account numbers in the customer table by adding 10000 to each number:
update customer set acctno = acctno + 10000;
Using the where clause, you can update only selected rows. The following example updates only the customer who meets the criteria defined in the where clause:
/* Update customer's account balance */
update customer
set cacctbal = cacctbal - :charges
where acctno = :checkout_form.acctno;
There are also query object and cursor versions of the update statement. Both of these update operations modify the values in the current row when the statement is executed. For examples of query object and cursor update statements, see
How You Can Use Query Objects and
How You Can Use Cursors to Access the Database.
Last modified date: 12/20/2023