Update Statement

The update DML operation modifies one or more existing sObject records, such as individual accounts or contactsinvoice statements, in your organization’s data. update is analogous to the UPDATE statement in SQL.

Syntax

update sObject

update sObject[]

Example

The following example updates the BillingCity field on a single account named 'Acme':
Account a = new Account(Name='Acme2');
insert(a);

Account myAcct = [SELECT Id, Name, BillingCity FROM Account WHERE Id = :a.Id];
myAcct.BillingCity = 'San Francisco'; 

try {
    update myAcct;
} catch (DmlException e) {
    // Process exception here
}
Note
For more information on processing DmlExceptions, see Bulk DML Exception Handling.
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.