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
  • 相关阅读:
    linux 6.9 补丁修补漏洞
    更改交换分区
    MariaDB Windows 安装
    关于Oracle内存分配-解决实际运行时最大Session数不一致远小于系统配置最大的Session数目
    Angular 相关概念
    实用工具推荐
    DDD目录结构
    全局异常处理区分返回响应类型是页面还是JSON
    Lambda学习总结(三)--方法引用
    Lambda学习总结(二)--Stream流
  • 原文地址:https://www.cnblogs.com/arcer/p/3029946.html
Copyright © 2011-2022 走看看