oracle我以前的资料2.1

/********************1用循环计算工资总和******************************/
declare
type emp_cur is ref cursor;
v_cur emp_cur;
v_type naemp%rowtype;
v_sum naemp.EMPSAL%type;
begin
open v_cur for select * from naemp where empdeptno=30;
fetch v_cur into v_type;
while v_cur%found
loop
v_sum:=v_sum+v_type.empsal;
end loop;
close v_cur;
end;


/***************************2用游标列出所有信息******************************/
declare
type emp_cur is ref cursor;
v_cur emp_cur;
v_type naemp%rowtype;
begin
open v_cur for select * from naemp;
fetch v_cur into v_type;
while v_cur%found
loop
dbms_output.PUT_LINE(v_type.empdeptno||' '||v_type.empno);
end loop;

end;
/**********************************3用联合数组打出所有信息**********************/
declare
type t1 is table of naemp%rowtype index by binary_integer;
tt t1;
begin
select empno,empname,empdeptno,empsal,empmanager bulk collect into tt from naemp;
for i in 1..tt.count
loop
dbms_output.PUT_LINE(tt(i).empno||' '||tt(i).empname||' '||tt(i).empdeptno||' '||tt(i).empsal||' '||tt(i).empmanager);
end loop;
end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值