Multiple choice technology databases

For which of the following tasks would it be most appropriate to use a PL/SQL WHILE loop?

  1. To add six new services to the SERVICE table

  2. To change MACHINE_ID 123456 to 456789 and change all others to 900000

  3. To change MACHINE_ID 123456 to 456789

  4. To add new services to the SERVICE table until finished

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

A WHILE loop is ideal when you need to repeat an action until a completion condition is met, which matches 'add new services until finished'. Options A and C describe single or fixed actions (adding 6 services, one specific update) which don't require looping. Option B describes a conditional update that can be done with a single UPDATE statement with CASE expression, not a loop.