Oracle
  Home arrow Oracle arrow Page 4 - Database Interaction with PL/SQL, Work...
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, Working with TABLE in Sub-programs, Parameter Modes
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 19
    2005-08-30

    Table of Contents:
  • Database Interaction with PL/SQL, Working with TABLE in Sub-programs, Parameter Modes
  • Returning PL/SQL TABLE from a FUNCTION to a PROCEDURE
  • What are IN types of parameters?
  • What are OUT types of parameters?
  • What is an IN OUT type of parameter?

  • 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, Working with TABLE in Sub-programs, Parameter Modes - What are OUT types of parameters?


    (Page 4 of 5 )

    This is a bit different (of course quite opposite) from the case we just finished discussing.  The IN parameter could never be modified (but only accessed).  The OUT parameter could never be accessed (but modified and indirectly returned back).  Let us consider the following example:

    declare

        b          number;

        procedure doSquare(a IN number,
                 
    z OUT number) is
       
    begin   

              z := a * a;

        end;
    begin
       
    doSquare(10,b);
       
    dbms_output.put_line('Square : ' || b);
    end;

    /

    Even though the above is a very simple program, it gives us a lot to discuss. First of all, you should observe that ‘b’ never gets initialized within the program.  It was just declared as being of type number and we are directly displaying it.  And we received a value of 100.  So, before displaying the value of ‘b’, we are calling a procedure named ‘doSquare’, which performs all of the magic.

    The statement ‘doSquare(10,b)’ calls the procedure ‘doSquare’ by sending 10 into the parameter ‘a’.  Just like 10, we are passing ‘b’ to ‘z’ (but as being of type OUT parameter).  Since ‘z’ is an OUT type of parameter, it will not expect any value from ‘b’.  Instead, it in turn reflects back its own value (value of ‘z’) to ‘b’.  That means the parameter ‘z’ returns back its own value directly into ‘b’.  It is another way of returning a value from a procedure (but indirectly, because we cannot use a RETURN statement with a procedure).  So, within the procedure ‘doSquare’, whenever ‘z’ gets modified, the variable ‘b’ also gets modified with the same value, and thus ‘z’ is called an OUT type of parameter.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my article on working with sub-programs with tables in PL/SQL....
     

       

    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