程序包就是一组相关的过程,函数,变量,常量和游标等PL/SQL 程序设计元素的组合
在plsql中使用包这种结构组织过程,函数,变量等可以使程序设计实现模块化,从而提高程序的编写效率
包分为包头和包体两个部分
包头里面定义了包里面应该包含的 变量,过程,函数 等
在包头里面需要定义包里面的函数,存储过程等
包体里面对包头中定义的函数存储过程等进行实现
sql语句演示:
建立包头:
create or replace package my_package is
type ny_cursor is ref cursor;
procedure my_procedure(out_cursor in out ny_cursor);
end my_package;
建立包体:
create or replace package body my_package is
procedure my_procedure(out_cursor in out ny_cursor) is
begin
open out_curso for select * from emp where deptno=10;
return;
end my_procedure;
end;