zoukankan      html  css  js  c++  java
  • Chapter 09 Creating Procedures 00

    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
  • 相关阅读:
    Knockout.Js官网学习(visible绑定)
    Entity Framework 简单增删改操作
    Knockout.Js官网学习(数组observable)
    Knockout.Js官网学习(监控属性Observables)
    Entity Framework 简单查询
    Java 使用getClass().getResourceAsStream()方法获取资源
    Virtualbox [The headers for the current running kernel were not found] (操作过程后还是失败,显示相同问题)
    为什么要在linux命令前加上 ./
    Redis need tcl 8.5 or newer
    JDK和Tomcat部署时,版本不同的问题解决
  • 原文地址:https://www.cnblogs.com/arcer/p/3029946.html
Copyright © 2011-2022 走看看