Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 95 discussion

Actual exam question from Salesforce's CRT-450
Question #: 95
Topic #: 1
[All CRT-450 Questions]

An Apex transaction inserts 100 Account records and 2,000 Contact records before encountering a DML exception when attempting to insert 500 Opportunity records.
The Account records are inserted by calling the database.insert() method with the allOrNone argument set to false. The Contact and Opportunity records are inserted using the standalone insert statement.
How many total records will be committed to the database in this transaction?

  • A. 2,000
  • B. 2,100
  • C. 0
  • D. 100
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
abdulAhad911
Highly Voted 3 years, 2 months ago
I think Answer is "0" because All insertions took place in one transaction and the transaction fails, so all records are rolledback even the one inserted form Database.insert().
upvoted 8 times
Yojit
3 years, 1 month ago
But if you set allornone to false then successful records get saved in database. So answer will be 100(Account records)
upvoted 6 times
PegasusFromUranus
2 years, 6 months ago
They will, as well as all 2000 contacts. But when erorr occurs later in Opportunities - it fails transaction and everything rollbacks
upvoted 7 times
BrucePark
1 year, 3 months ago
Why for all 2000 contacts? It says standalone insert statement was used.
upvoted 1 times
...
...
...
...
ABHI0O07
Most Recent 8 months ago
Selected Answer: C
c is correct
upvoted 1 times
...
ABHI0O07
8 months ago
option c is correct. replicate the scenario using this code List<Account> accountsToInsert = new List<Account>(); for(Integer i = 1; i <= 100; i++) { Account acc = new Account(); acc.Name = 'testaccount ' + String.valueOf(i); accountsToInsert.add(acc); } List<Contact> contactsToInsert = new List<Contact>(); for(Integer i = 1; i <= 2000; i++) { Contact con = new Contact(); con.LastName = 'testcontact ' + String.valueOf(i); contactsToInsert.add(con); } List<Opportunity> opportunitiesToInsert = new List<Opportunity>(); for(Integer i = 1; i <= 500; i++) { Opportunity opp = new Opportunity(); opp.Name = 'Test Opportunity ' + String.valueOf(i); // Set additional fields if needed opportunitiesToInsert.add(opp); } Database.insert(accountsToInsert,false); insert contactsToInsert; insert opportunitiesToInsert;
upvoted 1 times
...
helper_raw
11 months, 4 weeks ago
Selected Answer: C
Answer of this Question is D. All insertions took place in one transaction and the transaction fails, so all records are rolledback even the one inserted form Database.insert().
upvoted 1 times
helper_raw
11 months, 4 weeks ago
i mean answer of this Question is C
upvoted 2 times
...
...
chucksback
1 year, 2 months ago
I think D is correct but C (0) can also be correct. D because the first 100 account records should be inserted then the 2000 contacts would already be above the 150DML limit. but if the database.inser() false is used to insert opportunities then that'd fail because you are already exceeding DML limits. C would be correct in the event that all of this is in one transaction, however because the Insert and Database.Insert is separate transactions, I'm thinking 100 account records but because the contact is also there it could just roll back
upvoted 1 times
...
FerhatHappy
1 year, 11 months ago
Selected Answer: C
C is correct because all operations are in one transaction. If any operation in the transaction fails, all DML operation are rolledback
upvoted 3 times
...
Dean5555
2 years, 1 month ago
Selected Answer: C
The answer is C as explained
upvoted 3 times
...
PegasusFromUranus
2 years, 6 months ago
Selected Answer: C
Exception when inserting using standalone dmls fails transaction and all changes rollbacked. allOrNone = false allows you to skip erorrs when inserting records in the current Database.insert() method, but not in the whole transaction.
upvoted 4 times
_ApexPredator_
1 year, 11 months ago
Can you please provide a source to this in relation to allOrNone being used? I understand this happens when the insert is set to true, but set to false would suggest that partial is saved: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_bulk_exceptions.htm?q=allornone
upvoted 1 times
...
...
khoce
2 years, 6 months ago
Selected Answer: D
D is correct
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...