BC remote Oracle DBA - Call (800) 766-1884
Free Oracle Tips

Oracle Consulting Oracle Training Development

Remote DBA

 

Remote DBA Plans
Remote DBA Service

 
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Internals Magazine
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

   
  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

Remote DBA Service
 

Oracle Tuning Book

Free Oracle dictionary reference poster

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

North Carolina Oracle Users Group

 

 Arabian horse breeder

Seeing eye horses

 

 

Burleson is the American Team

American Flag

 

 

BC Remote Oracle Support
P.O. Box 511 • Kittrell, NC, 27544

Remote DBA

Remote DBA Services

 

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

Oracle® is the registered trademark of Oracle Corporation.