Wednesday 19 February 2014

Difference between Insert and Database.Insert in Salesforce



Database.Insert
ü  Database methods are static methods available in Database class.

ü  Roll back is supported.

ü  Includes the optional allorNone parameters that defaults true.

ü  In bulk operation if error occurs, the remaining records will be inserted i.e. partial DML operation.

ü  Database methods allows additional features such as truncation features.
Insert 
ü  Roll back is not supported.

ü  In bulk operation if error occurs, the execution will stop and throws an error.

Example

For example, if you are inserting is 1000 records, 500 records are correct and remaining 500 records is Invalid means,
ü  In insert Operation 1000 records are failed, because if one records is invalid or error means all other remaining records will not be inserted it will through error.

ü  In Database.insert 500 records are inserted, remaining 500 records is failed.(i.e. Partial DML Operation)

1 comment:

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...