Call (800) 766-1884 for Oracle support & training
Free Oracle Tips


Oracle Consulting Support
Oracle Upgrades
Use New Oracle Features
Oracle Replication Support
Oracle Training
Remote Oracle DBA
System Documentation
Oracle Tips
Oracle Performance
 

Free Oracle Tips


 

HTML Text

BC Oracle tuning

Oracle training

Oracle support

Remote Oracle

 

 

   
  Oracle Tips by Burleson

Local Modules

A local module is a procedure or function defined in the declaration section of another PL/SQL block.  Because it is defined in a block, its scope is only in the block that defined it.  The local module can not be called or executed by code outside of the defining block.  The example below is an anonymous PL/SQL block that has a function defined in the declaration section.

SQL> declare
  2    v_test varchar2(40) := '&string';
  3
  4    function get_length
  5      (v_str IN varchar2)
  6      return number
  7    as
  8    begin
  9      return length(v_str);
 10    end;
 11  begin
 12    dbms_output.put_line(v_test||' has
                 '||get_length(v_test)||' characters.');
 13  end;
 14  /
Enter value for string: Smitherdoodle
old   2:   v_test varchar2(40) := '&string';
new   2:   v_test varchar2(40) := 'Smitherdoodle';
Smitherdoodle has 13 characters.

PL/SQL procedure successfully completed.

The function get_length is defined in the anonymous block above and exist only within that block.  There are a number of reasons to use local modules.  First, by creating functions and procedures as local modules they are hidden from outside the defining block, allowing added functionality and code reuse while maintaining modularity.  The local modules are hidden from other code within the containing package. 

This protects object names and actions from code outside the defining block.  Another benefit is that if used properly, local modules can make the code easier to read and maintain.  However, these benefits can also be detractors.  Local modules can not be used by code outside of the defining block, thereby limiting code reuse to only the defining block.  Extensive use of local modules can lead to sections of code that perform the same functions located in multiple modules.  This can result in lower code quality, maintainability and performance. 


The above book excerpt is from:

Easy Oracle PL/SQL Programming

Get Started Fast with Working PL/SQL Code Examples

ISBN 0-9759135-7-3   

John Garmany 

http://www.rampant-books.com/book_2005_1_easy_plsql.htm

  
 

Oracle performance tuning software 
 
 
 
 

Oracle performance tuning book

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

   

Copyright © 1996 -  2011 by Burleson Enterprises. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.