If I recall correctly, you can have an overloaded function
or procedure in a package BUT they must be different
in the PARAMETERS and not in what they return.

You would need to have one of the functions have
VARCHAR2, VARCHAR2 for parameters

and the other needs to be another combination of
datatypes.

----- Original Message -----
To: "Multiple recipients of list ORACLE-L" <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 5:09 PM


> Dear List,
>
> First off, this is kind of long, so don't start reading unless you have
> some time. :)
>
> I've run into this before, and now I can't remember how to resolve it.
>
> ( database is 8.1.7.0 )
>
> The Signature of a procedure or function is made up of:
>
>   1. function or procedure name
>   2. data types of arguments
>   3. mode of arguments ( IN, OUT, IN OUT )
>   4.  return value in the case of a function
>
> There are some other special cases, but this is enough for this
discussion.
>
> The documentataion is quite clear on one thing;  changing the name of an
> argument will *not*  change the signature.
>
> Here's some code to demonstrate
>
> ==========================
>
> create or replace package ftest
> is
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return boolean;
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return varchar2;
>
> end;
> /
>
> show errors package ftest
>
> create or replace package body ftest
> is
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return boolean
>    is
>    begin
>       return true;
>    end;
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return varchar2
>    is
>       login_success boolean := false;
>    begin
>
>       login_success :=  login(
>          username_in
>          , password_in
>       );
>
>       if login_success then
>          return 'LOGIN';
>       else
>          return 'NOLOGIN';
>       end if;
>    end;
>
> end;
> /
>
> show errors package body ftest
> ===========================
>
> Try to compile this and you will get :
>
> Errors for PACKAGE BODY FTEST:
>
> LINE/COL
> --------------------------------------------------------------------------
-------
> ERROR
> --------------------------------------------------------------------------
--------------------------
> 21/3
> PL/SQL: Statement ignored
>
> 21/21
> PLS-00307: too many declarations of 'LOGIN' match this call
>
>
> The signatures of these two function are different:  one returns a boolean
> and the other returns a varchar.  The login() function that returns a
> varchar
> should be able to call a function of the same name and arguments that
> returns a boolean.  But it doesn't work.
>
> The code below does work.   Notice the two changes.  The login() function
> that returns a boolean now has a prefix of 'b_' on it's input arguments.
>
> The login() function that returns a varchar now uses named parameters to
> call the login() function that returns a boolean.
>
> Both of these changes are necessary to make this work.
>
> Any ideas?
>
> Thanks
>
> Jared
>
> ====================================================
>
>
> create or replace package ftest
> is
>
>    function login(
>       b_username_in varchar2
>       , b_password_in varchar2
>    ) return boolean;
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return varchar2;
>
> end;
> /
>
> show errors package ftest
>
> create or replace package body ftest
> is
>
>    function login(
>       b_username_in varchar2
>       , b_password_in varchar2
>    ) return boolean
>    is
>    begin
>       return true;
>    end;
>
>    function login(
>       username_in varchar2
>       , password_in varchar2
>    ) return varchar2
>    is
>       login_success boolean := false;
>    begin
>
>       login_success :=  login(
>          b_username_in => username_in
>          , b_password_in => password_in
>       );
>
>       if login_success then
>          return 'LOGIN';
>       else
>          return 'NOLOGIN';
>       end if;
>    end;
>
>
> end;
> /
>
> show errors package body ftest
>
> ====================================
>
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author:
>   INET: [EMAIL PROTECTED]
>
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
>
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Babette Turner-Underwood
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to