zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    如何制作对联式广告所需的flash图像文件
    GHOST重装系统详解
    Multipledimensional Vector,C++
    Dvbbs展区图片调用(向上滚动样式)
    fatal error C1001: INTERNAL COMPILER ERROR
    硬盘坏道的探测与恢复
    FreeBSD 使用手册
    全美电影票房排行(截止2010.12.19)
    Linux环境下的C/C+基础调试技术2——程序控制
    在freebsd下安装vim(Debian下类似)
  • 原文地址:https://www.cnblogs.com/arcer/p/3046743.html
Copyright © 2011-2022 走看看