如下表 SQLgt; set pagesize 60; SQLgt; run; 1* select * from employee NAME SALARY ---------- -
如下表
在这个表如果SALARY列小于2500 就加20%。这个很简单,但是要用把游标用进去就要如下思考了:
先建个游标,,遍历这个表在这个条件的数据。
SQL> create or replace procedure emp_test is v_name employee.name%type; v_sal employee.salary%type; cursor cursor_sal is select name,salary from employee where salary<2500; begin open cursor_sal ; loop fetch cursor_sal into v_name,v_sal; exit when cursor_sal%notfound; update employee set salary=salary*1.2 where name=v_name; end loop; close cursor_sal; end; / 过程已创建。