[Solved] Can we call a private procedure of a package from another package and can we call database procedure from a private package

[ad_1]

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

[ad_2]

solved Can we call a private procedure of a package from another package and can we call database procedure from a private package