How Calls Are Resolved?
The figure shows that how the PL/SQL compiler resolves the subprogram calls. When the compiler encounters the procedure or function call, it tries to discover a declaration that matches the call. The compiler first searches in the present scope and then, if necessary, in the successive enclosing scopes. The compiler stop searching if it finds one or further subprogram declarations in which the subprogram name match the name of the called subprogram.
To resolve the call along with the possibly like-named subprograms at similar level of the scope, the compiler should find an exact match between the actual and formal parameters. That is, they should match in the number, order, and datatype. If no match is found or if the multiple matches are found, the compilers generate the syntax error.
In the illustration below, you call the enclosing procedure swap from inside the function valid. Though, the compiler generates an error as neither declaration of swap inside the present scope matches the procedure call:
PROCEDURE swap (d1 DATE, d2 DATE) IS
FUNCTION valid (d DATE) RETURN BOOLEAN IS
PROCEDURE swap (n1 INTEGER, n2 INTEGER) IS BEGIN ... END;
PROCEDURE swap (n1 REAL, n2 REAL) IS BEGIN ... END;
Figure: How the PL/SQL Compiler Resolves Calls