本篇文章小编给大家分享一下Oracle游标简易用法,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
具体代码如下所示:
create or replace procedure NW_DelYW(iOPERATION_ID number, sUserID varchar2) is sCurDJBH yw_operation_link.djbh%type; cursor table_yw(ywid yw_operation.id%type) is select * from yw_operation_link t1 where t1.operation_id = ywid; begin for dr in table_yw(iOPERATION_ID) loop sCurDJBH := dr.djbh; --取得opercationid /* select t1.operation_id into sOperationID from yw_operation_link t1 where t1.djbh = sCurDJBH;*/ --写日志 insert into log_zfywinfo (DJBH, DJDL, DJXL, DLMC, XLMC, SLR, SLRID, SQRXM, FWZL, ZFRQ, ZFRID, zfr) select distinct sCurDJBH, t4.id, t3.id, t4.name, t3.name, t1.slry, t1.slryid, t1.SQRXM, t1.zl, sysdate, sUserID, (select tt.name from pw_user tt where tt.id=sUserID) from yw_operation t1 join yw_operation_link t2 on t2.operation_id = t1.ID join BUSINESS_TYPE t3 on t3.id = t1.business_id join BUSINESS_CLASS t4 on t4.id = t3.parent_id where t1.ID = dr.operation_id; exception when others then rollback; dbms_output.put_line(sqlerrm); end NW_DelYW;
Oracle使用cursor 游标循环添加删除更新。
知识点扩展:
Oracle游标简单示例
使用游标打印员工姓名和薪水
set serveroutput on; declare cursor cemp is select ename,sal from emp; cname emp.ename%type; csal emp.sal%type; begin open cemp; loop fetch cemp into cname,csal; exit when cemp%notfound; dbms_output.put_line(cname || '的薪水是' || csal); end loop; end; /
带参数的游标
使用游标打印某部门号的所有员工姓名
set serveroutput on; declare cursor cemp(cno emp.deptno%type) is select ename from emp where emp.deptno = cno; cname emp.ename%type; begin open cemp(10); loop fetch cemp into cname; exit when cemp%notfound; dbms_output.put_line(cname); end loop; end; /
迷你世界越南服 安卓版v1.7.15
迷你世界越南服是一款精美的3D沙盒游戏,拥有极高的创作自由度
糖饼外传内置菜单 安卓版v1.0.87
糖饼外传内置菜单是一款非常好玩的模拟经营类手游,玩家在游戏中
我的世界化学交换空岛整合包 最新版v1.0
我的世界化学交换空岛整合包是一款像素风格的沙盒生存游戏,游戏
创造厨房免广告版 v1.0.10
创造厨房无广告版是一款像素风模拟经营类手游,玩家们将在这里化
SimCity BuildIt无限金币版 安卓修改版v1.60.1.133743
SimCity BuildIt无限金币版是经过破解的版本,在