--存储过程
create or replace procedure p
is
cursor c is
select * from emp2 for update;
begin
for v_emp in c loop
if(v_emp.deptno=10)then
update emp2 set sal=sal+10 where current of c;
elsif(v_emp.deptno=20)then
update emp2 set sal=sal+20 where current of c;
else
update emp2 set sal=sal+50 where current of c;
end if;
end loop;
commit;
end;
select * from emp;
begin
p;
end;
exec;
show error;
--带参数的存储过程
create or replace procedure p
(v_a in number , v_b number ,v_ret out number , v_temp in out number)
is
begin
if(v_a>v_b)then
v_ret:=v_a;
else
v_ret:=v_b;
end if;
v_temp :=v_temp +10;
end;
--使用存储过程
declare
v_a number:=3;
v_b number :=4;
v_ret number;
v_temp number :=5;
begin
p(v_a,v_b,v_ret,v_temp);
dbms_output.put_line(v_temp);
dbms_output.put_line(v_temp);
end;