SunQuest
 
       Oracle
  Home arrow Oracle arrow Page 3 - Database Interaction with PL/SQL, User...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Database Interaction with PL/SQL, User-defined Packages
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2005-09-12

    Table of Contents:
  • Database Interaction with PL/SQL, User-defined Packages
  • Database interaction using a PACKAGE
  • Overloading sub-programs in a PACKAGE
  • TYPE declarations in package specification
  • How the above package works

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Database Interaction with PL/SQL, User-defined Packages - Overloading sub-programs in a PACKAGE


    (Page 3 of 5 )

    Those who are familiar with Object Oriented Programming (OOP) can easily understand the concept of overloading.  Briefly, having the same name for different sub-programs with different parameters can be called overloading sub-programs.  The following example gives you an illustration:

    create or replace package SamplePkg as
        procedure dispEmp;
        procedure dispEmp(p_deptno dept.deptno%type);
    end SamplePkg;
    /

    create or replace package body SamplePkg as
         procedure dispEmp as
             cursor c_emp is
                 select ename, sal from emp;
         begin
             for r_emp in c_emp
             loop
                 dbms_output.put_line (r_emp.ename || ',' || r_emp.sal);
             end loop;
          end;

          procedure dispEmp(p_deptno dept.deptno%type) as
              cursor c_emp is
                  select ename, sal from emp
                  where deptno = p_deptno;
          begin
              for r_emp in c_emp
              loop
              dbms_output.put_line (r_emp.ename || ',' || r_emp.sal);
              end loop;
          end;

    end SamplePkg;
    /

    Within the above package, we declared two sub-programs as having the same name.  But you should observe that the first sub-program doesn’t have any parameters, whereas the second sub-program does.  If you execute with the following statement:

    Execute SamplePkg.dispEmp;

    It would automatically call the first sub-program (because you didn’t provide any parameters).  If you execute with the following statement:

    Execute SamplePkg.dispEmp(10);

    It would automatically choose the second sub-program (because we provided a parameter).

    So, the selection of the respective sub-program will be automatically chosen by PL/SQL runtime based on the parameters we send.  In that way, we can write as many sub-programs as possible with the same name, but with some differences in parameters.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my new article on working with packages in PL/SQL. You can...
       · when i try one small example,it gives like thispackage,function,procedure and type...
     

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway