function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ankit bansalankit bansal 

Data loader behaviour when a record fails to upsert

I upserted 150 records wiith salesforce data loader. The batch size was set as 200.A single record in that 150 records failed to upload but the error was shown for all the 150 and none of the record was upserted,but in a seperate incident the data loader upserted 149 records and showed error for only that one record. What is this behaviour of data loader and how can it be changed ?
Best Answer chosen by ankit bansal
Ashish_SFDCAshish_SFDC
Hi Ankit, 


In APEX terms there are 2 options one is Insert and othetr one is Database.Insert 

In INsert - the system will either upload all the records or reject all the records. 

In Database.Insert the system will upload all those which pass the validations and only ones with errors will not be loaded. 

By Default Dataloader loads in Database.Insert type of uploads. 

Looks like it is a one off issue due to some internal server issues, Try again and it should load the ones without errors. 


Regards,
Ashish

All Answers

Ashish_SFDCAshish_SFDC
Hi Ankit, 


In APEX terms there are 2 options one is Insert and othetr one is Database.Insert 

In INsert - the system will either upload all the records or reject all the records. 

In Database.Insert the system will upload all those which pass the validations and only ones with errors will not be loaded. 

By Default Dataloader loads in Database.Insert type of uploads. 

Looks like it is a one off issue due to some internal server issues, Try again and it should load the ones without errors. 


Regards,
Ashish
This was selected as the best answer
Rajesh PotnuruRajesh Potnuru
Hi Ankit,

What is the difference between database.insert and insert ?
Ans:
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.
Midles SmithMidles Smith
Thank you so much for this. I was into this issue and tired to tinker around to check if its possible but couldnt get it done. Now that i have seen the way you did it, thanks guys
with
regards
https://www.ucbrowser.vip/  (https://www.ucbrowser.vip/https://shareit.onl/ https://mxplayer.pro/