PL/SQL Programming-Package

Source: Internet
Author: User

1, the package in the Plsql is equivalent to the packages in Java, the main benefits are (1) to prevent named Pollution, (2) The function is unified, (3) Allow overloading, (4) can hide the core code, (5) The most important is to disconnect the dependency chain.

2, for a program requires a lot of code, need to a large number of stored procedures must be implemented with the package, once the program loaded in, and then can be called.

3, when the package is under construction, the basic step is (1) Create packages, in the Inside Declaration procedure, (2) and then is the create packaging body, in the package body inside the code to write procedure.

4, in the package can be built procedure, but also can establish this function, which are encapsulated together, into a private resource is very easy to protect the program, while the code is a one-time transfer into the memory, execution is very fast.

5, in short, for a simple program to establish a stored procedure procedure, but for the complex program needs to build package.
Sql> Create or ReplacePackage Sp_package is  2  procedureSp_pack_pro1 (id_invarchar2, name_invarchar2); 3  functionSP_PACK_FUN1 (mon_in Number, id_invarchar2)return  Number; 4  End; 5  /Package created SQL>SQL> Create or ReplacePackage Body Sp_package is  2  procedureSp_pack_pro1 (id_invarchar2, name_invarchar2) is  3  begin  4  UpdateMyTestSetName=Name_inwhereId=id_in; 5  End; 6  functionSP_PACK_FUN1 (mon_in Number, id_invarchar2)  7  return  Number  is  8Sal_monsum Number(7,2); 9  begin Ten  SelectSalary*Mon_in intoSal_monsum fromMyTestwhereId=id_in; One  returnsal_monsum; A  End;  -  End;  -   the  /Package body created SQL> execSp_package.sp_pack_pro1 ('Wuwuwu','1'); PL/SqlprocedureSuccessfully completed

PL/SQL Programming-Package

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.