This discussion is archived
4 Replies Latest reply: May 2, 2013 12:35 PM by ANNEC RSS

call a function in a package body

ANNEC Newbie
Currently Being Moderated
I am new to Oralce, I am tried to call a function in an exiting package body using the package specification. function.
But it failed , it says wrong numbers or types of parameters. I see the functions are defined in the package body with two definitions but different numbers of parameters. One has only one parmenter, the other has 3.
But in the packgage definition is has the function with one parameter.
So when I call using 3 parameters, it gives the error.

Why is that?

Thanks
  • 1. Re: call a function in a package body
    sb92075 Guru
    Currently Being Moderated
    875563 wrote:
    I am new to Oralce, I am tried to call a function in an exiting package body using the package specification. function.
    But it failed , it says wrong numbers or types of parameters. I see the functions are defined in the package body with two definitions but different numbers of parameters. One has only one parmenter, the other has 3.
    But in the packgage definition is has the function with one parameter.
    So when I call using 3 parameters, it gives the error.

    Why is that?

    Thanks
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

    I don't know what you have.
    I don't know what you do.
    I don't know what you see.
    It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.
  • 2. Re: call a function in a package body
    Frank Kulash Guru
    Currently Being Moderated
    Hi,
    875563 wrote:
    I am new to Oralce, I am tried to call a function in an exiting package body using the package specification. function.
    But it failed , it says wrong numbers or types of parameters. I see the functions are defined in the package body with two definitions but different numbers of parameters. One has only one parmenter, the other has 3.
    But in the packgage definition is has the function with one parameter.
    So when I call using 3 parameters, it gives the error.

    Why is that?
    Only the functions that are in the package spec (or head) can be called from outside of the package.
    Functions that appear in the package body. but not in the package spec, can only be called by other functions or procedures in the package.

    If you need to call the 3-argument function from outside of the same package, then declare it in the package spec.
  • 3. Re: call a function in a package body
    santoshkbh Newbie
    Currently Being Moderated
    If you are calling the function with 3 parameters outside the package then it will give error as it seems to be defined in package body only. you have to define that function in the package spec to make it public so that you can call it or else you can call this function only in same package.
  • 4. Re: call a function in a package body
    ANNEC Newbie
    Currently Being Moderated
    Thanks, that is what I think too, I got the confirmation, thanks much

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points