Skip to Main Content
  • Questions
  • based on multiple packages and procedure

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Pradeep.

Asked: June 22, 2017 - 2:37 pm UTC

Last updated: June 29, 2017 - 1:58 am UTC

Version: 10.2.0

Viewed 1000+ times

You Asked

Can we access the procedure in a package outside the package using another package?

i.e. i need to access a package procedure outside of another package (i need to call from 2nd package to access the first package procedure)

and Connor said...

Packages have public and private procedures. (It is one the benefits of them).

So iF you have procedures defined in the *specification*, then they can be called from anywhere (other packages, procedures, etc), eg

package PKG is
  procedure P1;
end;

package body PKG is
  procedure P1 is
  begin
     ...
  end;

  procedure P2 is
  begin
     ...
  end;

end;


then you can call PKG.P1 from anywhere. You can only call P2 from within the PKG package.

More reading here

http://www.oracle.com/technetwork/issue-archive/2005/05-may/o35plsql-085074.html

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thank u so much

A reader, June 24, 2017 - 6:26 am UTC


Allen Marshall, June 28, 2017 - 11:09 am UTC

Similarly, you can call those public procedures within a package from a standalone PL/SQL function in order to use those procedures in a SQL statement. The sp may be quite complex but if it returns a value of interest it can be wrapped with the function and used to incorporate the processing complexity in a SQL starement while generally speaking simplifying the statement radically.
Connor McDonald
June 29, 2017 - 1:58 am UTC

nice input

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library