1.

What Is The Difference Between Database.insert And Insert?

Answer»

insert is the DML statement which is same as databse.insert.

However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)

IMPORTANT DIFFERENCE:

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

insert is the DML statement which is same as databse.insert.

However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)

Important Difference:



Discussion

No Comment Found