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) A stored procedure on the server.

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

  3. c) A standalone procedure on the client machine.

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

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

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

Option E is correct because the code is only used within the program unit ORDERTOTAL. A local subprogram (procedure or function defined within ORDERTOTAL) is the most appropriate choice - it encapsulates the logic, makes it reusable within the unit, and keeps the scope limited. Stored procedures (A) would make it globally available on the server, which is unnecessary. PL/SQL libraries (B) or standalone procedures (C) are also overkill for local-only use. Option D is incorrect because putting code directly in the body doesn't make it reusable from multiple places within ORDERTOTAL.