您好,欢迎来到保捱科技网。
搜索
您的当前位置:首页Oracle中用游标更新字段值的面试题

Oracle中用游标更新字段值的面试题

来源:保捱科技网

如下表 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; / 过程已创建。

Copyright © 2019- baoaiwan.cn 版权所有 赣ICP备2024042794号-3

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务