Experience Salesforce
Update | APEX DML Standalone Statements
What You’ll Learn
- Apex Update DML Statement
Topics
- What Is DML In Salesforce?
- Insert | APEX DML Standalone Statements
- Update | APEX DML Standalone Statements
- Upsert | APEX DML Standalone Statements
- Delete | Apex DML Standalone Statement
- Undelete | Apex DML Standalone Statement
- Merge | APEX DML Standalone Statements
- APEX DML Statements Best Practices
- Database Class in APEX
- Empty Recycle Bin
- Count Query | Method in Apex Database Class
- Lead Conversion | Method in Apex Database Class
- Transaction Control and Rollback
- Database Class Method Result Object
Apex Update DML Statement
To update an existing record, you need to use the update statement.
Example 1:
public static void main() {
Account a = [SELECT Name from Account WHERE Name like‘ Sh % ’LIMIT 1]
a.name = ‘Cyntexa’;
update a;
}
Example 2:
List < Contact > conList = [SELECT firstname, lastname FROM Contact WHERE
createdDate = Today
];
Integer i = 1;
for (Contact cc: conList) {
cc.firstname = cc.firstname + i);
i++;
}
update conList;
Note:
We cannot modify a list or collection in a for-each loop where its even elements are iterated. (infinite loop)
Next TopicNeed Extra Support? Our FREE study materials have got you covered.
Our expert-prepared study materials provide the answers you need. Clear your doubts and improve your skills with detailed notes from industry professionals.