如下表
SQL> set pagesize 60;
SQL> run;
1* select * from employee
NAME SALARY
---------- ----------
SMITH 800
ALLEN 1600
WARD 1250
JONES 2975
MARTIN 1250
BLAKE 2850
CLARK 2450
SCOTT 3000
KING 5000
TURNER 1500
ADAMS 1100
JAMES 950
FORD 3000
MILLER 1300
已选择14行。
在这个表如果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 set serveroutput on ;
SQL> exec emp_test;