SQL> create or replace procedure sp_pro6(id_in varchar2) is
2 v_bonus number(6,2);
3 begin
4 select bonus into v_bonus from mytest where id=id_in;
5 if v_bonus=0 then
6 update mytest set bonus=100 where id=id_in;
7 else
8 update mytest set bonus=v_bonus+300 where id=id_in;
9 end if;
10 end;
11 /
Procedure created
SQL> select * from mytest;
ID NAME PASSWD SALARY BONUS
----- -------------------- -------------------- -------- --------
1 123 123 120.00 0.00
2 gaodingle!!!! 123 120.00 0.00
3 gagaga 123 120.00 100.00
4 125555 passwd 120.00 100.00
SQL> exec sp_pro6(1);
PL/SQL procedure successfully completed
SQL> select * from mytest;
ID NAME PASSWD SALARY BONUS
----- -------------------- -------------------- -------- --------
1 123 123 120.00 100.00
2 gaodingle!!!! 123 120.00 0.00
3 gagaga 123 120.00 100.00
4 125555 passwd 120.00 100.00