Activity › Forums › Salesforce® Discussions › How database.insert() is different from insert() in Salesforce?
-
How database.insert() is different from insert() in Salesforce?
Posted by Anjali on July 24, 2020 at 7:46 AMHow database.insert() is different from insert() in Salesforce?
Sumit kumar replied 5 years, 10 months ago 4 Members · 3 Replies -
3 Replies
-
<div>If we use the DML statement (Insert) in bulk operation, then if error occurs the execution will stop. In that case Apex code throws an error and none of the record will insert to the database.</div>
If we use DML database methods (Database.Insert) in bulk operation, 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. - [adinserter block='9']
-
Please have a look at my blog for the answer that why DML and database methods are different:
https://www.forcetalks.com/blog/dml-statements-vs-database-methods-in-salesforce/ -
<div>If we use the DML statement (Insert) in bulk operation, then if error occurs the execution will stop. In that case Apex code throws an error and none of the record will insert to the database.</div>If we use DML database methods (Database.Insert) in bulk operation, 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.
Log In to reply.