What correction should be performed in the above code?

Examine the following code that you plan to execute:


What correction should be performed in the above code?
A. The PROC2 procedure code should be defined in the package body.
B. The PROC3 procedure should be declared in the package specification.
C. The PROC3 procedure header should be declared at the beginning of the package body.
D. The variable x must be declared in the package body and removed from the specification,

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “What correction should be performed in the above code?

  1. Agree with everyone – correct answer is A.
    Got same errors:

    CREATE OR REPLACE PACKAGE p1 IS
    x NUMBER;
    PROCEDURE proc1;
    PROCEDURE proc2;
    END p1;
    /

    CREATE OR REPLACE PACKAGE BODY p1 IS
    PROCEDURE proc1 IS
    BEGIN
    x := 1;
    END;
    PROCEDURE proc3 IS
    BEGIN
    DBMS_OUTPUT.PUT_LINE(x);
    END proc3;
    END p1;
    /

    LINE/COL ERROR
    ——– —————————————————————–
    4/11 PLS-00323: subprogram or cursor ‘PROC2’ is declared in a package
    specification and must be defined in the package body

  2. Errors: PACKAGE BODY P1
    Line/Col: 4/15 PLS-00323: subprogram or cursor ‘PROC2’ is declared in a package specification and must be defined in the package body

  3. CREATE OR REPLACE PACKAGE p1 IS
    x NUMBER;
    PROCEDURE proc1;
    PROCEDURE proc2;
    END p1;

    CREATE OR REPLACE PACKAGE BODY p1 IS
    PROCEDURE proc1 IS
    BEGIN
    x := 1;
    END;
    PROCEDURE proc3 IS
    BEGIN
    DBMS_OUTPUT.PUT_LINE(x);
    END proc3;
    END p1;
    –Errors: check compiler log

    –CORRECT AS ANSWER A
    CREATE OR REPLACE PACKAGE p1 IS
    x NUMBER;
    PROCEDURE proc1;
    PROCEDURE proc2;
    — PROCEDURE proc3;
    END p1;
    –Package P1 compiled

    CREATE OR REPLACE PACKAGE BODY p1 IS
    PROCEDURE proc1 IS
    BEGIN
    x := 1;
    END;
    –/*
    PROCEDURE proc2 IS –ANSWER A
    BEGIN
    DBMS_OUTPUT.PUT_LINE(‘proc2’);
    END proc2;
    –*/
    PROCEDURE proc3 IS
    BEGIN
    DBMS_OUTPUT.PUT_LINE(x);
    END proc3;
    END p1;
    –Package body P1 compiled

    EXEC p1.proc1;
    –PL/SQL procedure successfully completed.
    EXEC p1.proc2;
    –PL/SQL procedure successfully completed.
    EXEC p1.proc3;
    — PLS-00302: component ‘PROC3’ must be declared (…)

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.