PL/SQL lets you overload subprogram names. That is,
you can use the same name for several different subprograms as long as their
formal parameters differ in number, order, or datatype family.
Restrictions
Only local or packaged subprograms can be overloaded.
Therefore, you cannot overload standalone subprograms. Also, you cannot
overload two subprograms if their formal parameters differ only in name or
parameter mode. For example, you cannot overload the following two procedures:
PROCEDURE reconcile (acctno IN INTEGER) IS
BEGIN
...
END;
PROCEDURE reconcile (acctno OUT INTEGER) IS
BEGIN
...
END;
Furthermore, you cannot overload two subprograms if their
formal parameters differ only in datatype and the different datatypes are in
the same family. For instance, you cannot overload the following procedures
because the datatypes INTEGER and REAL are in the same family:
PROCEDURE charge_back (amount INTEGER) IS
BEGIN
...
END;
PROCEDURE charge_back (amount REAL) IS
BEGIN
...
END;
Likewise, you cannot overload two subprograms if their
formal parameters differ only in subtype and the different subtypes are based
on types in the same family. For example, you cannot overload the following
procedures because the base types CHAR and LONG are in the same family:
DECLARE
SUBTYPE Delimiter IS CHAR;
SUBTYPE Text IS LONG;
...
PROCEDURE scan (x Delimiter) IS
BEGIN ... END;
PROCEDURE scan (x Text) IS
BEGIN ... END;
Finally, you cannot overload two functions that differ only
in return type (the datatype of the result value) even if the types are in
different families. For example, you cannot overload the following functions:
FUNCTION acct_ok (acct_id INTEGER) RETURN BOOLEAN
IS
BEGIN ... END;
FUNCTION acct_ok (acct_id INTEGER) RETURN INTEGER
IS
BEGIN
... END;
No comments:
Post a Comment