Oracle Stored Procedure (iii) package

Source: Internet
Author: User

Package:

A package is a combination of PL/SQL programming elements, such as related processes, functions, variables, cursors, and constants. It features an object-oriented programming language and encapsulates these PL/SQL programming elements. A package is similar to a class in a C ++ or Java program, and a variable is equivalent to a member variable in the class. A process and function are equivalent to a method, and related modules are classified into packages, developers can use object-oriented methods to develop stored procedures to improve system performance. Similar to the class, program elements in the package are also divided into two types: public elements and private elements. The difference between these two elements is that they allow different program scopes, that is, they have different scopes. A public element can be called not only by functions and procedures in the package, but also by PL/SQL blocks outside the package. Private elements can only be called by functions or processes in the package.

Advantages of using the package:

In PL/SQL design, packages can not only modularize the program, but also hide the information used in the package. Writing packages can improve the program running efficiency. Because, when the program calls a function or process inside the package for the first time, Oracle transfers the entire package to the memory. When the program calls the elements in the package again, Oracle directly reads the data from the memory, you do not need to perform disk I/O operations to improve program execution efficiency.

Package composition:

Package definition: the package definition partially declares the data type, variable, constant, cursor, subroutine, function and other elements in the package. These elements are the common elements of the package.

Package subject: the package subject defines the specific implementation of the package definition part. You can also declare and implement private elements in the package body.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.