Multiple choice technology databases

  1. Examine this package body: CREATE OR REPLACE PACKAGE BODY forward_pack IS V_sum NUMBER; - 44 - PROCEDURE calc_ord(. . . ); PROCEDURE generate_summary(. . . ) IS BEGIN Calc_ord(. . . ); . . . END calc_ord; END forward_pack; / Which construct has a forward declaration?

  1. a) V_SUM

  2. b) CALC_ORD.

  3. c) FORWARD_PACK

  4. d) GENERATE_SUMMARY.

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

A forward declaration is used in PL/SQL when a subprogram calls another subprogram that has not yet been defined in the code. Declaring the header of CALC_ORD beforehand allows GENERATE_SUMMARY to reference it.

AI explanation

To answer this question, let's go through each option to understand which construct has a forward declaration:

Option A) V_SUM - This option does not have a forward declaration. V_SUM is a variable declaration and does not require a forward declaration.

Option B) CALC_ORD - This option has a forward declaration. The PROCEDURE calc_ord is declared in the package body, but its full implementation is not provided in the given code. This indicates that there is a forward declaration for the calc_ord procedure.

Option C) FORWARD_PACK - This option does not have a forward declaration. FORWARD_PACK is the name of the package body itself and does not require a forward declaration.

Option D) GENERATE_SUMMARY - This option does not have a forward declaration. GENERATE_SUMMARY is a procedure declared and implemented within the package body, so it does not need a forward declaration.

The correct answer is Option B) CALC_ORD. This option has a forward declaration because the PROCEDURE calc_ord is declared without its full implementation in the given code.