Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What is the problem with database update?

Asked by Aishwarya Jhadav Sep 22, 2022 1.7K views 1 answer
Share

About this question

 I have some accounts to update but some validation rules can fail.

So to avoid this I use the Database. Update() function to update accounts even if some DML exception occurs.

try {
        acc.Name = 'test';
    }
 system. Debug ('one');
 system. Debug('two');
} catch(Exception e) {
    system. Debug (txt);
}
    List accounts = [select Id from Account];
  for(Account acc : accounts) {
 List result Database. Update(accounts, false);
    String txt = e.getMessage();

But only the first log is displayed. I don't have the second one and I don't reach the catch block. I can see that some validation rules fail on some account names.

Do you know what happens ? If a DML exception occurs on a Database. Update() what happens ?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.