2 Replies Latest reply: Jan 18, 2013 10:19 AM by rp0428 RSS

    Calling private function present in a package

    927509
      HI.

      I am using SQL developer 1.5.5,

      I need to call a function which is inside a package body, but this function is not present in the package specification.
      This can be accessed by other procedures in the same package.

      I need to just call this function in this package in the SQL developer,

      I tried,
      - package_name.function_name(:par1,:par2)
      - exec package_name.function_name(:par1,:par2)
      - call package_name.function_name(:par1,:par2)
      - select package_name.function_name(:par1,:par2) from dual;


      none of these seems to work.


      Any idea how do I call a this function, which is not part of package specification.


      If this question doesn't fit in this forum,
      apologies.. and kindly point where this question belongs.


      Thank you.
        • 1. Re: Calling private function present in a package
          riedelme
          924506 wrote:
          HI.

          I am using SQL developer 1.5.5,

          I need to call a function which is inside a package body, but this function is not present in the package specification.
          This can be accessed by other procedures in the same package.
          This is actually a PL/SQL issue and would be better asked in the SQL/PLSQL forum. The forum tag clearly says "Not for general SQL/PLSQL questions".

          But since you're here anyway ...

          You will have to either make the function itself public or call it through another function or procedure that is public
          • 2. Re: Calling private function present in a package
            rp0428
            >
            none of these seems to work.

            Any idea how do I call a this function, which is not part of package specification.
            >
            You can't - that has been documented in the Oracle docs from the beginning.

            See 'What is a PL/SQL Package' in the PL/SQL Language doc
            http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/packages.htm
            >
            What is a PL/SQL Package?
            A package is a schema object that groups logically related PL/SQL types, variables, and subprograms. Packages usually have two parts, a specification ("spec") and a body; sometimes the body is unnecessary.

            The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines the queries for the cursors and the code for the subprograms.
            . . .
            The spec holds public declarations, which are visible to stored subprograms and other code outside the package. You must declare subprograms at the end of the spec after all other items (except pragmas that name a specific function; such pragmas must follow the function spec).