Activity Forums Salesforce® Discussions What is the difference between Dml insert and Database insert in salesforce?

  • Manpreet

    Member
    April 4, 2017 at 6:17 am

    Hi suraj,
    bellow 2 points explations of your question
    1.If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop .and Apex code throws an error which can be handled in try catch block.

    2.Unlike DML statements, Database methods have an optional allOrNone parameter that allows you to specify whether the operation should partially succeed. When this parameter is set to false, if errors occur on a partial set of records, the successful records will be committed and errors will be returned for the failed records. Also, no exceptions are thrown with the partial success option.

    Database.insert(recordList, false);

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos