包头负责声明,包体负责实现
在out参数中使用光标,包头包体等。
用pl/sql工具如何便捷创建包头?
out参数中使用光标
申明结构
包头
包体
包头:声明的所有方法,包括存储函数、存储方法
CREATE OR REPLACE PACKAGE MYPACKAGE AS
type empcursor is ref cursor;
procedure queryEmpList(dno in number,empList out empcursor); END MYPACKAGE;
包体(需要实现包头中声明的所有方法,包括存储函数、存储方法):
CREATE OR REPLACE PACKAGE BODY MYPACKAGE AS
procedure queryEmpList(dno in number,empList out empcursor) AS
BEGIN
open empList for select * from emp where deptno=dno;
END queryEmpList;
END MYPACKAGE;
-- 使用desc查看程序包的结构
desc MYPACKAGE
使用包
包头:
create or replace package 包名 as
type 返回名 is ref cursor;
procedure 存储过程名 (参数列表);
end package;
包体:
begin
open 游标 for select * from table where X=X
end;
/
包体
包的声明
只负责声明包中的结构