Activity Forums Salesforce® Discussions How database.insert() is different from insert() in Salesforce?

  • MOHIT

    Member
    July 24, 2020 at 8:54 am

    <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.

  • Udit

    Member
    July 31, 2020 at 3:08 pm

    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/

    DML Statements vs Database Methods in Salesforce

  • Sumit

    Member
    August 3, 2020 at 4:59 am

    <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.

Popular Salesforce Blogs

Popular Salesforce Videos