-6

call database procedure in private package

  • 1
    The first part is 'no', that's what makes it private (procedure in package body but not declared in spec). [Read more](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/lnpls/plsql-packages.html#GUID-8D02540E-C697-4498-9261-848F6D4E5CB5). What do you mean by 'private package' though? – Alex Poole Jul 19 '19 at 17:39

1 Answers1

4

If by private, you mean a procedure that's defined in the package body and not exposed in header, then no. The other package won't be able to "see" the procedure.

SQL> CREATE OR REPLACE PACKAGE foo AS END; -- No "public" procedures/functions
  2  /

Package FOO compiled

SQL> CREATE OR REPLACE PACKAGE BODY foo
  2  AS
  3    PROCEDURE priv IS BEGIN NULL; END; -- "Private" procedure
  4  END;
  5  /

Package Body FOO compiled

SQL> CREATE OR REPLACE PACKAGE other_pkg
  2  AS
  3    PROCEDURE call_priv_proc;
  4  END;
  5  /

Package OTHER_PKG compiled

SQL> CREATE OR REPLACE PACKAGE BODY other_pkg
  2  AS
  3    PROCEDURE call_priv_proc
  4    IS
  5    BEGIN
  6      foo.priv;
  7    END;
  8  END;
  9  /

Package Body OTHER_PKG compiled

LINE/COL  ERROR
--------- -------------------------------------------------------------
6/5       PL/SQL: Statement ignored
6/9       PLS-00302: component 'PRIV' must be declared
Errors: check compiler log

If by database procedure, you mean a standalone procedure not in a package, then yes - provided that the caller has EXECUTE permission on the procedure. Whether the procedure is defined with Invoker's or Definer's rights also comes into play. See Invokers and Definers Rights

cdub
  • 1,420
  • 6
  • 10