Multiple choice technology databases

You want to create a PL/SQL block of code that calculates discounts on customer orders. This code will be invoked from several places, but only within the program unit ORDERTOTAL. What is the most appropriate location to store the code that calculates the discounts?

  1. A stored procedure on the server.

  2. A block of code in a PL/SQL library.

  3. A standalone procedure on the client machine.

  4. A block of code in the body of the program unit ORDERTOTAL.

  5. A local subprogram defined within the program unit ORDERTOTAL.

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

A local subprogram within ORDERTOTAL is ideal because it's scoped only to that unit (avoiding global scope pollution) while being reusable from multiple places within ORDERTOTAL. Stored procedures or standalone code would be overly broad for this requirement.