日期:2014-05-17  浏览次数:20771 次

【偶结贴一向很快 ^_^】问个简单的存储过程代码----错在哪里?
小弟最近几天在学存储过程 碰到问题一堆 
先感谢下csdn的大侠们。虽然我的问题比较cai,但是大侠们仍谆谆教导 ,感动ing 

下面这个简单的加薪代码,给工资等于2459的员工统一加上1000元 不知道错在哪里?

SQL code
create or replace procedure lee_update_sala
as
cursor c_row
is
select * from lee_emp_0714 for update of sala;

begin

for v_row in c_row loop

if v_row.sala=2459 then sala:=sala+1000;
end loop;
end;




运行时 提示
(S224) Expecting: statement_terminator BEGIN CASE DECLARE END IDENTIFIER IF LOOP

------解决方案--------------------
晕没写end if;
------解决方案--------------------
sala:=sala+1000;
改成update lee_emp_0714 set sala=sala+1000 where sala=2459;
------解决方案--------------------
还有就一条sql语句就出来的东西为什么写procedure?
直接这样写就行了啊
SQL code
update lee_emp_0714 set sala=sala+1000 where sala=2459;

------解决方案--------------------
SQL code

错误很多。
修改如下:
create or replace procedure lee_update_sala
as
cursor c_row
is
select * from lee_emp_0714 where sala=2459 for update of sala;
begin
for v_row in c_row loop
 update lee_emp_0714 set sala=sala+1000 where current of c_row;
end loop;
commit;
end;
/