Package private procedure/function (not declared in package specification) need to be aware of placement
For example, the following package,procedure a wants to call Procedure B,
CREATE OR REPLACE PACKAGE AAAAA authid current_user as
PROCEDURE A;
End AAAAA;
CREATE OR REPLACE PACKAGE body AAAAA as
PROCEDURE A is
BEGIN
B;
End;
PROCEDURE B is the
BEGIN
dbms_output.put_line (' in PROCEDURE b ');
End;
End AAAAA;
There will be an error: PLS-00313: ' B ' not declared in this scope
Reason: B is not public procedure, if a wants to call B, then B's definition must be placed at the front of a.
PLS-00313: "string" not declared in this scope
Cause:there is no declaration for the given identifier within the scope of reference. The identifier might is misspelled, its declaration might to be faulty, or the declaration might is placed incorrectly in the Block structure.
Action:check the spelling and declaration of the identifier. Also confirm the declaration is placed correctly in the block structure.
So the correct wording is:
CREATE OR REPLACE PACKAGE body AAAAA as
PROCEDURE B are
BEGIN
dbms_output.put_line (' in PROCEDURE b ');
End;
PROCEDURE A is
BEGIN
B;
End;
End AAAAA;
Or, if you really want to put B in the back, then you can be in front of the declaration, so that there is no call to the back, there is no error, this is a good habit.
CREATE OR REPLACE PACKAGE body AAAAA as
PROCEDURE B;
PROCEDURE A is
BEGIN
B;
End;
PROCEDURE B is the
BEGIN
dbms_output.put_line (' in PROCEDURE b ');
End;
End AAAAA;
reference:http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P 11_question_id:11471812249709