如下表
- 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行。
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; / 过程已创建。
- SQL> set serveroutput on ;
- SQL> exec emp_test;
- PL/SQL 过程已成功完成。
- SQL> select * from employee;
- NAME SALARY
- ---------- ----------
- SMITH 1382.4
- ALLEN 1920
- WARD 1500
- JONES 2975
- MARTIN 1500
- BLAKE 2850
- CLARK 2940
- SCOTT 3000
- KING 5000
- TURNER 1800
- ADAMS 1320
- JAMES 1368
- FORD 3000
- MILLER 1560
- 已选择14行。