Syntax for creating an Oracle package

Source: Internet
Author: User

Creating an Oracle package is one of the most common operations when we use an Oracle database. The following describes the syntax for creating an Oracle package.

A package is a container that binds processes, functions, and data structures. A package consists of two parts: external visual package specifications, including function headers and process headers, the package body contains the declaration, execution, and exception handling of all bundled processes and functions.

The packaged PL/SQL program is very different from the one not packaged. The package data exists throughout the user's session. When the user obtains the package execution authorization, it is equivalent to obtaining permissions for all programs and data structures in the package specification. However, you cannot only authorize a function or process in the package. The package can reload processes and functions. In the package, multiple programs can be declared with the same name. during runtime, the correct program is called based on the number of parameters and data types.

To create an Oracle package, you must first create a package specification. The syntax for creating an Oracle package specification is as follows:

 
 
  1. CREATE [OR REPLACE] PACKAGE package_name  
  2. {AS|IS}  
  3. public_variable_declarations |  
  4. public_type_declarations |  
  5. public_exception_declarations |  
  6. public_cursor_declarations |  
  7. function_declarations |  
  8. procedure_specifications  
  9. END [package_name]  

Use the create package body statement to CREATE a package body:

 
 
  1. CREATE [OR REPLACE] PACKAGE BODY package_name  
  2. {AS|IS}  
  3. private_variable_declarations |  
  4. private_type_declarations |  
  5. private_exception_declarations |  
  6. private_cursor_declarations |  
  7. function_declarations |  
  8. procedure_specifications  
  9. END [package_name]  

Private Data structures are those inside the package body and are invisible to the called program.
 

Differences between Oracle procedures and functions

Example of Oracle over () function usage

Use of Oracle to_char Functions

Two cases of Java calling Oracle Functions

Implementation of oracle function return table

Related Article

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.