国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

詳解Oracle游標的簡易用法

2020-07-26 13:58:06
字體:
來源:轉載
供稿:網友

下面看下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;declarecursor 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;/ 

總結

以上所述是小編給大家介紹的詳解Oracle游標的簡易用法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 治多县| 衡东县| 仲巴县| 富蕴县| 芷江| 米林县| 隆昌县| 五家渠市| 老河口市| 安达市| 徐汇区| 团风县| 淮滨县| 张掖市| 布尔津县| 东阿县| 通辽市| 额尔古纳市| 翁源县| 嵊泗县| 莫力| 桂阳县| 西藏| 工布江达县| 古田县| 荣成市| 芮城县| 玉田县| 宁津县| 苍梧县| 岐山县| 乌什县| 富平县| 镇雄县| 龙门县| 杂多县| 吉林省| 江孜县| 雷波县| 阳朔县| 永仁县|