Random guy
Random guy

Reputation: 923

Error while creating body in package in oracle

I have a package which has specs and body .

Its spec is

CREATE OR REPLACE PACKAGE OT.PK_TEST IS
FUNCTION PRNT_STRNG RETURN VARCHAR2;
PROCEDURE PR_SUPERHERO(F_NAME VARCHAR2,L_NAME VARCHAR2);

PROCEDURE PR_new(full_name VARCHAR2);
END PK_TEST;
/

Its body is:

CREATE OR REPLACE PACKAGE BODY OT.PK_TEST IS
FUNCTION PRNT_STRNG 
RETURN VARCHAR2
IS
BEGIN
RETURN 'SUMAN';
END PRNT_STRNG;
PROCEDURE PR_SUPERHERO(F_NAME VARCHAR2,L_NAME VARCHAR2) 
IS
OLD_NAME VARCHAR2(255);
BEGIN
DBMS_OUTPUT.PUT_LINE(F_NAME);
DBMS_OUTPUT.PUT_LINE(L_NAME);
OT.PR_new(f_name||L_NAME);
DBMS_OUTPUT.PUT_LINE('----------');
OLD_NAME :=OT.PRNT_STRNG;
DBMS_OUTPUT.PUT_LINE(OLD_NAME);
END PR_SUPERHERO;
PROCEDURE PR_new(full_name VARCHAR2)
IS
V_NAME VARCHAR2(255) :=FULL_NAME;
BEGIN

DBMS_OUTPUT.PUT_LINE(V_NAME);
END PR_new;
END PK_TEST;
/

But when i compile body,I got the error as:

[Warning] ORA-24344: success with compilation error
14/1    PLS-00201: identifier 'OT.PR_NEW' must be declared
14/1    PL/SQL: Statement ignored
16/12   PLS-00201: identifier 'OT.PRNT_STRNG' must be declared
16/1    PL/SQL: Statement ignored
 (1: 0): Warning: compiled but with compilation errors

Why is this error coming?What is the mistake I did?

Upvotes: 1

Views: 281

Answers (1)

Justin Cave
Justin Cave

Reputation: 231661

Normally, if you want to call a method in a package from a different method in the same package, there is no need to qualify the method name. If you just call

  PR_new(f_name||L_NAME);

that defaults to the pr_new procedure in the pk_test package in the ot schema. If you do want to qualify the procedure name, you can either do so as package.method or schema.package.method. So either

  pk_test.PR_new(f_name||L_NAME);

or

  ot.pk_test.PR_new(f_name||L_NAME);

would be legal.

Upvotes: 6

Related Questions