Oracle
  Home arrow Oracle arrow Database Interaction with PL/SQL, Named Notations, Storing Procedures and Functions
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
ORACLE

Database Interaction with PL/SQL, Named Notations, Storing Procedures and Functions
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 23
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek