SunQuest
 
       Oracle
  Home arrow Oracle arrow Page 2 - 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
     
    IBM developerWorks
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Database Interaction with PL/SQL, User-defined Packages - Database interaction using a PACKAGE


    (Page 2 of 5 )

    There would be nothing new in this section apart from the syntax of package.  All the procedures and functions being implemented inside the package have been thoroughly discussed in my previous articles.  So, let us have a good example of using a package interacting with a database.

    create or replace package SamplePkg as
        procedure dispEmp;
        procedure dispDept;
    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 dispDept as
            cursor c_dept is
                select deptno,dname from dept;
        begin
            for r_dept in c_dept
                loop
                    dbms_output.put_line (r_dept.deptno || ',' ||
                    r_dept.dname);
                end loop;
        end;

    end SamplePkg;
    /

    To execute each of those procedures separately, you can use the following commands:

    execute SamplePkg.dispEmp;
    execute SamplePkg.dispDept;

    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 4 hosted by Hostway