Oracle
  Home arrow Oracle arrow Database Interaction with PL/SQL, RECO...
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
eWeek
 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, RECORD and TABLE in Sub-programs
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2005-08-23

    Table of Contents:
  • Database Interaction with PL/SQL, RECORD and TABLE in Sub-programs
  • Mixing PROCEDURE and FUNCTION
  • Using RECORD with sub-programs
  • Returning a RECORD from FUNCTION
  • Working with PL/SQL TABLE and sub-programs

  • 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

    Virtual Tradeshows by Ziff Davis Enterprise - A Unique Opportunity to Connect with IT Experts, Access Information, and Gain Insight on today's Technology

    Database Interaction with PL/SQL, RECORD and TABLE in Sub-programs
    (Page 1 of 5 )

    This is part 14 of a series of articles focusing on database interactions with Oracle PL/SQL. In my previous article, we concentrated on some tips for using procedures together with the introduction to functions. In this article we will look through several examples that cover using sub-programs in a very effective manner. I suggest you to go through part two in order to follow this article properly.

    Please note that all the examples in this series have been tested only with Oracle 10g. I didn’t really test them with all the previous versions of Oracle. I suggest you to refer the documentation of respective version you are using, if any of the programs failed to execute.

    More about FUNCTION

    My previous article actually stopped at a simple example on FUNCTION. Now we shall extend its limit. Consider the following example:

    declare

    CURSOR c_emp is

    select ename,deptno from emp;

    function getDname(p_deptno dept.deptno%type) return varchar2 is

    v_dname dept.dname%type;

    begin

    select dname into v_dname

    from dept where deptno = p_deptno;

     

    return v_dname;

    end;

    begin

    for r_emp in c_emp

    loop

    dbms_output.put_line(r_emp.ename || ',' || getDname(r_emp.deptno));

    end loop;

    end;

    The above program really makes use of FUNCTION properly. We are sending ‘deptno’ as a parameter to the function ‘getDname’ which returns the department name back to the main program. Actually we can store the value returned back by ‘getDname’ (demonstrated in part 13), but it would be easy to write directly within the DBMS_OUTPUT statement in the main program as above.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my article on working with RECORD and TABLE in PL/SQL. You can...
     

       

    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