其实包头就相当于java的类,里面定义了多个方法,包体就是实现方法里具体的逻辑
在out参数中引用光标,解决如果返回值过多的情况.
下面这个示例就是包头和包体的示例
执行的时候先执行包头,再执行包体
--2、查询某个部门中的所有员工信息 ----> 返回的是集合
--包头
create or replace package mypackage is
type empcursor is ref cursor;--这句话是自定义一个变量类型为光标类型其实就是光标,不定义也可以.
--下面这句就是包头里有个存储过程,定义一个存储过程,可以定义多个.
procedure queryEmpList(dno in number,empList out empcursor);
end mypackage;
--包体,用来实现包头里的具体的存储过程或者存储函数
create or replace package body mypackage is
procedure queryEmpList(dno in number,empList out empcursor)
as
begin
open empList for select * from emp where deptno=dno;
end;
end mypackage;