create or replace procedure sp_pro8(spNo number) is
v_job emp.job%type;
begin
select job into v_job from emp where empno=spNo;
if v_job='PRESIDENT' then
update emp set sal=sal+1000 where empno=spNo;
elsif v_job='MANAGER' then
update emp set sal=sal+500 where empno=spNo;
else
update emp set sal=sal+200 where empno=spNo;
end if;
end;
一个匿名块使用游标
declare
---定义游标类型
type sp_emp_cursor is ref cursor;
---定义一个游标变量
test_cursor sp_emp_cursor;
---定义变量
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
---执行
---把test_cousor和一个select 结合
open test_cursor for select ename, sal from emp where deptno = &aa;
---循环取出
loop
fetch test_cursor into v_ename, v_sal;
---判断是否test_cursor为空
exit when test_cursor%notfound;
dbms_output.put_line('名字:'||v_ename ||'工资:'||v_sal);
end loop
---关闭游标
close test_cursor;
end;