• PL/SQL高级Creating Packages (00)


    Objectives

    After completing this lesson,you should be able to do the following

    • Describe packages and list their components
    • Create a package to group together related variables,cursors,constants,exceptions,procedures,and fuctions.
    • Designate a package construct as either public or private
    • Invoke a package construct
    • Describe the use of a bodiless package

    Lesson Agenda

    • Identifying the benefits and the components of packages
    • Working with packages
      • -Creating the package specification and body
      • -Invoking the package subprograms
      • -Removing a package
      • -Displaying the package information

    What Are PL/SQL Packages?

    • A package is a schema object that groups logically related PL/SQL types,variables,and subprograms.
    • Packages usually have two parts:
      • -A specification(spec)
      • -A body
    • The specification is the interface to the package.It declare the types,variables,constants,exceptions,cursors,and subprograms that can be referenced from outside the package.
    • The body defines the queries for the cursors and the code for the subprograms.
    • Enable the Oracle server to read multiple objects into memory at once.

    Advantages of Using Packages

    • Modularity:Encapsulating related constructs
    • Easier maintenance:Keepling logically related functionality together
    • Easier apllication design:Coding and compiling the specification and body separately
    • Hiding information:
      • Only the declarations  in the package sepcification are visible and accessible to applications.
      • Private constructs in the package body are hidden and inaccessible.
      • All coding is hidden in the package body
    • Added functionality:Persistency of public variables and cursors
    • Better performance:
      • -The entire package is loaded into memory when the package is first referenced.
      • -The is only one copy in memory for all users
      • -The dependency hierarchy is simplified.
    • Overloading:Multiple subprograms of the same name
    • The package is a powerful and important element of the PL/SQL language.It should be the cornerstone of any application development project.
    • Always construct your application around packages;avoid standlone procedure and fuctions.Even if tody you think that only one procedure is needed for a certain area of functionality,in the future you will almost certainly have two,then three,and then a dozen.At which point,you will find yourself saying,"Gee,I should really collect those together in a package!" That`s fine,except that now you have to go back to all the invocations of those unpackaged procedures and functions and add in the package prefix.So start wit a package and save yourself the trouble.
  • 相关阅读:
    通过代码学REST之二——Restlet框架学习
    页面解析工具:HtmlParser学习
    游标的使用
    软件测试工具杂谈
    XUL资料
    MYSQL5.1修改表名与复制表结构的定时器与存储过程
    mysql 5.7以上版本下载及安装
    AnyChart图表控件(一)简介
    AnyChart图表控件(二)优势
    踩坑 Pycharm 2020.1.1 安装/ JetBrains破解/ anacode配置
  • 原文地址:https://www.cnblogs.com/arcer/p/3046743.html
Copyright © 2020-2023  润新知