Exforsys.com
 
Home Tutorials Oracle 9i
 

Tutorial 15: Oracle 9i : Oracle Packages

 

Tutorial 15: Oracle 9i : Oracle Packages - Page 2

Page 2 of 2



Private and Public Items in packages


Items declared in package body are private. They can only be accessed within the package. Where as items declared in package specification is public and is available outside package. It is explained in the following example.


The package shown in Fig 1 contains a variable Age_limit which is accessed by the program given below.



Overloading Packaged Subprograms:


Similar to the overloading concept in other programming languages PL/SQL also allows you to overload its subprograms.


We can have more than one subprogram with the same name within a package

Following examples better explain this concept.






Writing Cursor spec and body separately using Packages


The cursor specification can be written separate from its body using packages. It allows you to change cursor body without changing the cursor specification. Cursor coded in the package spec need to have a return type.

CURSOR cursor_name [(parameter [, parameter]...)] RETURN return_type;

The following examples explain how cursor can be declared and defined using packages.



 




Below given is the example that explains how to access the cursor values.




Download Sample Scripts




First Page: Tutorial 15: Oracle 9i : Oracle Packages


Read Next: Tutorial 16: Oracle 9i: Oracle Utilities



 

 

Comments


Raghvendra Pratap Singh said:

  Can we call cursor as an anonymous block
August 16, 2006, 9:53 am

arul1 said:

  pl/sql packeges concepts are easy to understand
August 2, 2007, 3:25 am

hasan amin said:

  thanx a billion , where million is too little :) for this clear , helpful and specific explanation .
it really helped me and made that stuff crystal clear to me ..
thanx again .
May 27, 2008, 5:47 pm

Lokesh Devanga said:

  You will provide somemore Examples
June 18, 2008, 4:29 am

charles said:

  It is very simple and example also easy to understand.It is realy helpful to me
October 20, 2008, 9:40 am

raj said:

  it is very good but you should provide some more examples
November 20, 2008, 9:32 am

kumar ashish said:

  it is good but more examples ,some complex ones, should be provided.
December 1, 2008, 12:00 am

Yogesh Tiwari said:

  can any body explain me how package provides information hiding facility in oracle
explain with examples

pls help me...


December 30, 2008, 5:43 am

damania said:

  can anybody answer this query:
i need to check if a package of the name 'x' exists in a particulas db. what will be the sql command for that?
select x from dual; doesnt work.
January 22, 2009, 1:14 am

Franco Springveldt said:

  you should query the user_source table as such:
SELECT text from user_source WHERE
name = 'x' AND type = 'PACKAGE';

or something like that
April 21, 2009, 1:45 pm

rashmipriya said:

  you should query the user_source table as such:
SELECT text from user_source WHERE
name = 'x' AND type = 'PACKAGE';

June 9, 2009, 8:09 am

vesi taskiran said:

  I have about 250 procedures and each 25 is a group. These procedures are created dynamically by using definition tables. What I want to do is to group each 25 procedure in a package but I can not execute these procedures in a package since the length of the string is to big to execute. I use execute immediate or dbms_sql.parse to execute the string. What should I do ? Is there a method of adding procedures to a package ?

Thanks in advance.
September 4, 2009, 8:22 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape