A package specification can not only contain sub-programs, it can even contain TYPE declarations as well. What is the use of declaring TYPE declarations at the level of package specification? Why don’t we declare the same within the sub-programs (as we usually do)? If we declare any TYPE declaration within the package specification, it will be available to the public. The word ‘public’ has several meanings here. Any data structure declared in the specification of a package is a global, public data structure. This means that any program outside of the package can access the data structure. Let us see some of the issues of “public” declarations within package specification.
This makes life easier in almost all aspects without remembering and re-declaring the same TYPE again and again. You can also create a package of constants which are used throughout all of your programs. Then all developers will reference the packaged constants instead of hardcoding the values into their programs. It also proves the concept of single definition at single location, reused several times at several locations. Let’s see an example for the above theory: create or replace package SamplePkg as create or replace package body SamplePkg as procedure dispEmp(p_deptno dept.deptno%type) as end SamplePkg; My next section would help you to understand the above package.
blog comments powered by Disqus |