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