out参数以及使用光标问题

/*
查询某个员工的姓名 月薪 职位

*/
create or replace procedure queryEmpInfo(eno in number,
pename out varchar2,
psal out number,
pjob out varchar2)
as
begin
select ename,sal,empjob into pename,psal,pjob from emp where empno=eno;

end;
/

–光标: 使用游标查询员工姓名和工资,并打印

/*
光标的属性:
**%isopen 是否被打开
%rowcount 行数
%notfound 是否有值**
*/

set serveroutput on

declare
–光标
cursor cemp is select ename,sal from emp;
pename emp.ename%type;
psal emp.sal%type;
begin
open cemp;
loop
–从集合中取值
fetch cemp into pename,psal;
**
exit when cemp%notfound;

dbms_output.put_line(pename||'的薪水是'||psal);

end loop;
close cemp;
end;
/

查询某个部门中所有员工的所有信息

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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值