Sunday, February 8, 2015

What is the difference between Insert and Database.Insert in salesforce.


Insert
If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop. In that case Apex code throws an error and none of the record is inserted to the database.


Database.Insert
If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done. The only record throwing an error will not be inserted / updated.

So you should use Database.insert in any bulk dml operation if you are not monitoring the code properly

Regards,
Naveen,
http://www.autorabit.com/.

No comments:

Post a Comment