As a Salesforce application developer, we always have a question like how many ways we can perform the DML operations when dealing with transactions. The answer is Salesforce provides 2 ways to perform the DML operations. Let us understand the difference between DML Statements and Database methods in Salesforce.
Let’s start with an example where we wanted to insert the account record.
Using the above approach if any account record insert fails then all the records will fail. so what if We wanted to save the records that were successfully processed and only fail those that failed? then we will use Database class methods for DML
Syntax: Database.insert(List<sObject> object, Boolean);
Syntax: Database.update(List<sObject> object, Boolean);
Syntax: Database.delete(List<sObject> object, Boolean);
Database.Query method in Salesforce takes a single string parameter as a Query and returns the List<sObject> as a result.
SOSL (Salesforce Object Search Language) is used to search a keyword in single or multiple objects. List<List<sObject>>
No DML is Allowed in the result of SOQL.
[…] https://www.pantherschools.com/database-dml-methods-sosl-in-salesforce/ […]
[…] https://www.pantherschools.com/database-dml-methods-sosl-in-salesforce/ […]