How to call a private package level function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M

    How to call a private package level function

    Hello

    I am trying to build an Oracle PL/SQL Package. Some functions should
    only be visible from the package, while other functions need to be
    called from outside.

    I tried the following:

    -- begin code snippet ---

    create or replace package test
    is
    FUNCTION MYPUBLICFUNC (parm in integer) return INTEGER;
    end;
    /
    create or replace package body test
    AS
    FUNCTION MYPUBLICFUNC (parm in integer)
    return integer
    IS
    BEGIN
    RETURN test.MYPRIVATEF UNC(parm);
    END;

    FUNCTION MYPRIVATEFUNC (parm in integer)
    return integer
    IS
    BEGIN
    RETURN 3*parm;
    END;
    END;

    -- End Code snippet ---

    This results in an Error Message:
    PLS-00013: MYPRIVATEFUNC ist für diesen Geltungsbereich nicht
    definiert.

    What am I doing wrong here ??

    Kind Regards
    Mat Hess

    Please reply to the newsgroup
  • Mat Hess

    #2
    Re: How to call a private package level function

    I figured it out.

    If I want a function or a procedure to be private, I just add it to
    the body of the package. But note: The private function must be
    declared before any code that calls it!

    create or replace package test
    is
    FUNCTION MYPUBLICFUNC (parm in integer) return INTEGER;
    end;
    /
    create or replace package body test
    AS
    -- MUST Declare HERE
    FUNCTION MYPRIVATEFUNC (parm in integer)
    return integer
    IS
    BEGIN
    RETURN 3*parm;
    END;

    FUNCTION MYPUBLICFUNC (parm in integer)
    return integer
    IS
    BEGIN
    RETURN test.MYPRIVATEF UNC(parm);
    END;

    -- MUST NOT DECARE HERE!!


    END;

    Regards Mat

    Comment

    Working...