SunQuest
 
       Oracle
  Home arrow Oracle arrow Page 3 - 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 IN types of parameters?


    (Page 3 of 5 )

    Let us consider the following program:

    declare

       procedure dispValue(a number) is

            b          number;

       begin   

            a := a + 10;
           
    b := a * a;
           
    dbms_output.put_line('Value : ' || b);

        end;

    begin

        dispValue(10);

    end;

    /

    Is the above program syntactically wrong?  Is it logically wrong?  But, the program raises an error!  The error message would be “expression 'A' cannot be used as an assignment target.”  Try to remove the statement “a := a + 10” and execute the program again.  No doubt, it gets executed successfully.  What is the problem?

    Actually, we can rewrite the same program with the specification of IN as the following (which is actually the default):

    declare

        procedure dispValue(a IN number) is

              b          number;

        begin   

              b := a * a;
             
    dbms_output.put_line('Value : ' || b);

        end;

    begin

        dispValue(10);

    end;

    If you don’t specify anything to the parameter, IN becomes the default behind the screens.  That means it just behaves like an “IN”PUT to the procedure.  But it could not be modified within the sub-program.  The value present in a variable which is defined with “IN” can never be modified within the sub-program.  Now I hope you can understand why you received the error.  It not only affects ordinary types of variables, it could even be related to %TYPE or %ROWTYPE or RECORD or even TABLE.

    That is why, to remove the confusion, it is always suggested that you use the type of parameter along with the parameter which could be either IN or OUT or even both IN OUT together (dealt with later).

    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

    IBM developerWorks




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