You need to sign in to do that
Don't have an account?
anjisalesforce@gmail.com
What is the difference between Database.insert and Insert?
HI all,
Q) What is the difference between Database.insert and Insert?
can you please give me rply its very urgent
thanks for your help....
it is amazing what a google search will get you
http://lmgtfy.com/?q=difference+between+database.insert+and+insert+salesforce
look at the first result
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.
Thanks,
Anil
insert will call direct dml operation for record/s and fail the whole operation in case any single record failed to insert.
In case of database.insert it accept second parameter to create difference than just insert call.
Second parameter decide whether rest of records should be inserted if any record failed to insert.
Let me know if you get it or not.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_insert.htm
Insert vs Database.insert() in Salesforce (http://www.salesforceadda.com/2017/08/insert-vs-databaseinsert-in-salesforce.html)