Oracle
  Home arrow Oracle arrow Database Interaction with PL/SQL, Name...
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 
 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, Named Notations, Storing Procedures and Functions
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 21
    2005-09-06

    Table of Contents:
  • Database Interaction with PL/SQL, Named Notations, Storing Procedures and Functions
  • What are Parameter Default values?
  • What are STORED PROCEDURES?
  • What are STORED FUNCTIONS?
  • PACKAGE and PACKAGE BODY

  • 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, Named Notations, Storing Procedures and Functions
    (Page 1 of 5 )

    This is part 16 of a series of articles focusing on database interactions with Oracle PL/SQL. In my previous article, we worked with PL/SQL TABLE types in between sub-programs. In this article, we will look into Named Notation, default values of parameters, stored procedures, stored functions and finally introduce the concepts of package and package body.

    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 refer to the documentation of the respective version you are using, if any of the programs failed to execute.

    What is Named Notation?

    When we pass parameter values to a PL/SQL program, we are passing parameter values using positional notation. That means the first value goes to the first parameter, second to the second parameter and so on. What If I want the first value to go to the second parameter, the second value to the third parameter, the third value to the first parameter, and so on? This is where the concept of named notation comes in.

    Using named notation, you can pass the values of parameters in any order you want regardless of the position.  The following is a sample program:

    declare
     procedure dispEmp(p_sal emp.sal%type, p_deptno emp.deptno%type) is
     begin
      for r_emp in (select ename from emp where sal > p_sal and deptno = p_deptno)
      loop
       dbms_output.put_line(r_emp.ename);
      end loop;
     end;
    BEGIN
     dispEmp(1000,10);
     dbms_output.put_line('-------------');
     dispEmp(p_sal => 1000, p_deptno => 10);
     dbms_output.put_line('--------------');
     dispEmp(p_deptno => 10, p_sal => 1000);
    END;

    I hope the procedure ‘dispEmp’ is quite understandable. The only issue on which we need to concentrate is the statements in the main program. The first statement is as follows:

    dispEmp(1000,10);

    The above statement is straightforward. The 1000 gets into ‘p_sal’ and the 10 gets into ‘p_deptno’.  This is positional notation. Based on the position, the respective parameter name gets chosen.  The next statement is as follows:

    dispEmp(p_sal => 1000, p_deptno => 10);

    The above statement explicitly says that 1000 has to be assigned to ‘p_sal’ and 10 has to be assigned to ‘p_deptno’.  This is named notation.  In the named notation, we need to specify parameter names (even though it is not that necessary in the above statement).  The next statement is as follows:

    dispEmp(p_deptno => 10, p_sal => 1000);

    The above statement explicitly says that 10 has to be assigned to ‘p_deptno’ and 1000 has to be assigned to ‘p_sal’. This is also named notation. But it will not give any error and in all three cases, the result would be the same. You can observe that I changed the order according to my requirement.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my article on working with stored procedures and functions in...
     

       

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