000-349 · Question #23
A developer is loading the following records into a database: A,A,A,A B,B,B,B A,A,A,A C,C,C,C The database record has four fields each field will contain one letter from the file above. The update…
The correct answer is C. 2. With no PDATE flag and an update key on the first field, the second occurrence of key 'A' causes an insert failure; OnFailure-Rollback rolls back that operation and halts further processing, leaving only the two previously committed records.
Question
A developer is loading the following records into a database:
A,A,A,A B,B,B,B A,A,A,A C,C,C,C The database record has four fields each field will contain one letter from the file above. The update key in the .MDQ file is set to the first field of the table. The PDATE flag is not set on the card but OnFailure->Rollback is set. Using the adapter trace below, how many record will be inserted into the database?
Options
- A0
- B1
- C2
- D3
- E4
How the community answered
(45 responses)- A2% (1)
- B13% (6)
- C76% (34)
- D2% (1)
- E7% (3)
Why each option
With no PDATE flag and an update key on the first field, the second occurrence of key 'A' causes an insert failure; OnFailure-Rollback rolls back that operation and halts further processing, leaving only the two previously committed records.
Zero inserts would only result if OnFailure-Rollback performed a global rollback of all previously committed records, which is not the behavior described in this scenario.
One insert would imply B,B,B,B also failed, but its first-field key 'B' is unique at insertion time so it commits successfully.
The first record (A,A,A,A) and the second record (B,B,B,B) are inserted successfully because their first-field keys are unique at the time of insertion, committing 2 records. When the third record (A,A,A,A) is processed, the duplicate key 'A' causes an insert failure because PDATE is not set to allow updates. OnFailure-Rollback rolls back the failed transaction and stops further processing, so C,C,C,C is never inserted, leaving exactly 2 records in the database.
Three inserts would require C,C,C,C to also be processed, but the rollback triggered by the duplicate 'A' key halts execution before that record is reached.
Four inserts is impossible because the second A,A,A,A record violates the unique constraint enforced by the update key on the first field.
Concept tested: Database adapter insert behavior with duplicate update key and rollback
Topics
Community Discussion
No community discussion yet for this question.