Chapter -09 Creating Procedures 00
2013-04-19 11:18
357 查看
Objectives
After competing this lesson,you should be able to do the following:Identify the benefits of modualarized and layered subprogram design.
Create and call procedures.
Use formal and actual parameters
Use positional,named ,or mixed notation for passing parameters.
Identify the available parameter-passing modes.
Handle exceptions in procedures.
Remove a procedure
Display the prcedures`s information.
Lesson Agenda
Using a modularized and layered subprogram desing and identifying the benefits of subprograms.Working with procedures
-Creating and calling procedures
-Identifying the available parameter-passing modes
-Using formal and actual parameters
-Using positional,named,or mixed notation
Handing execptions in procedures,removing a procedure,and displaying the procedures`s information.
Creating a Modularized Subprogram Desgin
Modularize code into subprograms.
1、Locate code sequences repeated more than onec.
2、Create subprogram P containing the repeated code.
3、Modify original code to invoke the new subprogram.
Creating a Layered Sumprogram Desgin
Create subprogram layers for you application.Data access subprogram layer with SQL logic.
Business logic subprogram layer,which may or may not use the data access layer.
Modularizing Development with PL/SQL Blocks
PL/SQL is a block-structed language.The PL/SQL code block helps modularize code by using:-Anonymous blocks
-Procedures and Functions
-Packages
-Database triggers
The benefits of using modular program constructs are:
-Easy maintenance
-Improved data security and integrity
-Improved performance
-Improved code clarity
Anonymous Blocks:Overview
Anonymous blocks:Form the basic PL/SQL block structure
Initiate PL/SQL processing tasks from applications
Can be nested within the executable section of any PL/SQL block.
[DECLARE -- Declarationg Section (Optional) variable declarations;...] BEGIN --Executable Section(Mandatory) SQL or PL/SQL statements; [EXCEPTION --Exception Section (Optional) WHEN exception THEN statements;] END; --End of BLock(Mandatory)
PL/SQL Run-time Architecture
What Are PL/SQL Subprograms?
A PL/SQL subprogram is a named PL/SQL block that can be called with a set fo prameters.You can declare and define a subprogram within either a PL/SQL block or another subprogram.
A subprogram consists of a specification and a body
A subprogram can be a procedure or a function.
Typically,you use a procedure to perform an action and a fuction to compute and return a value.
Subprograms can be grouped into PL/SQL packages.
The benefits of Using PL/SQL Subprograms
Differences Between Anonymous Blocks and Subprograms
Anonymous Blocks | Subprograms |
Unnamed PL/SQL blocks | Named PL/SQL blocks |
Compiled every time | Compiled only once |
Not stored in the database | Stored in the database |
Cannot be invoked by other applicatons | Names and,therefore,can be invoked by other applicaitons |
Do not return values | Subprograms called functions must return values. |
Cannot take parameters | Can take parameters |
相关文章推荐
- [bbk2340] 第45集 - Chapter 09-Optimizing Sore Perations(00)
- [bbk2190] 第31集 - Chapter 09-Optimizing Sore Perations(00)
- Chapter 09-Manipulating Data - 01
- Chapter -09 Creating Procedures 03
- Chapter 09-Manipulation Data - 02
- Chapter -09 Creating Procedures 04
- arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry.
- Chapter 09-Manipulation Data - 03
- [bbk3019] 第60集 - Chapter 15-Application Tuning(00)
- 初识设计模式 chapter 09-迭代器与组合模式
- [bbk4981]第08集 - Chapter 05- Writing Control Structures(00)
- [bbk2341] 第46集 - Chapter 09-Optimizing Sore Perations(01)
- 第08、09讲:Chapter 03--Managing an Oracle Instance.swf
- [bbk2342] 第47集 - Chapter 09-Optimizing Sore Perations(02)
- [bbk3204] 第67集 -Chapter 17-Monitoring and Detecting Lock Contention(00)
- 《代码大全2》阅读笔记09--Chapter 16 Controlling Loops
- Chapter -00 Overview to PL/SQL
- [bbk2191] 第32集 - Chapter 09-Optimizing Sore Perations(01)
- [bbk2192] 第33集 - Chapter 09-Optimizing Sore Perations(02)
- [bbk2193] 第34集 - Chapter 09-Optimizing Sore Perations(03)