Apex Database operations
In Apex code, it is possible to interact with the Salesforce database in one of two ways: as Database Manipulation Language (DML) statements or using Apex Database
class methods. DML statements take the form of insert, update, upsert, or delete operations. Take the following example of a DML insert statement:
public class dmlStatementTest {
public void testStatement() {
List<Account> accounts;
accounts.add(new Account(Name='Packt UK'));
accounts.add(new Account(Name='Packt India'));
insert accounts;
}
}
Database Apex methods work slightly differently because rather than using a keyword such as insert or update, you call a method of the Database
class instead. I’d...