Activity Forums Salesforce® Discussions What is the difference between insert() and database .insert() in Salesforce?

  • Marziya

    Member
    January 24, 2020 at 2:35 pm

    Hello Ratnesh,

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

  • Ayush

    Member
    January 24, 2020 at 2:38 pm

    Using the insert method we can insert the records but if any error occurs in any record system will throw an error insertion fail and none of the records are inserted. If we want to execute partially success of bulk insert operation we will use database .insert.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos