Question 1
The `products` table currently holds these rows: ```text PRODUCT_ID NAME UNIT_PRICE ---------- ---------- ---------- 1 Gadget 25.00 2 Gizmo 40.00 3 Doohickey 12.50 4 Widget 99.00 ``` The `orders` table has no row whose `ORDER_ID` is 2000 or greater, and `ORDER_ID` is its primary key. How many rows does the following statement insert? ```sql INSERT FIRST WHEN unit_price >= 25 THEN INTO orders (order_id, product_id, quantity, order_date) VALUES (2000 + product_id, product_id, 1, DATE '2025-04-01') INTO orders (order_id, product_id, quantity, order_date) VALUES (3000 + product_id, product_id, 2, DATE '2025-04-01') WHEN unit_price >= 90 THEN INTO orders (order_id, product_id, quantity, order_date) VALUES (4000 + product_id, product_id, 3, DATE '2025-04-01') SELECT product_id, unit_price FROM products ```
A. 6Correct answer
For each source row Oracle evaluates the WHEN clauses top to bottom and executes only the INTO list of the first true condition. 25.00, 40.00 and 99.00 all satisfy `>= 25` first, and that clause holds two INTO clauses, so each contributes 2 rows; 12.50 satisfies no condition and, with no ELSE clause, is discarded — 3 x 2 + 0 = 6 rows inserted.
B. 3
Assumes INSERT FIRST produces at most one target row per source row. The unit of work is the INTO clause, not the WHEN clause: a single WHEN ... THEN may carry a list of INTO clauses and every one of them fires for a row that reaches it, so the three qualifying source rows yield two rows each.
C. 5
Routes the 99.00 row to the `>= 90` branch — it treats INSERT FIRST as choosing the most specific matching condition. FIRST means positionally first: 99.00 already satisfies `>= 25`, which is listed earlier, so the `>= 90` branch is never reached by any row.
D. 7
Applies INSERT ALL semantics, where every WHEN clause is evaluated independently, so 99.00 would fire both branches (2 + 1 rows) for a total of 7. INSERT FIRST explicitly skips all remaining WHEN clauses once one evaluates to TRUE.
Explanation
In a conditional multitable insert, `FIRST` makes the WHEN clauses mutually exclusive per source row: Oracle evaluates them in the order written and executes only the INTO list belonging to the first condition that is TRUE, skipping every later clause for that row. A single WHEN ... THEN may contain several INTO clauses, and each of them inserts its own row, so the total is counted per INTO clause rather than per source row. A source row for which no WHEN condition is TRUE is simply not inserted unless an ELSE clause supplies a target.