Oracle游标的简易用法

2022-10-17,,,

 1 create or replace procedure nw_delyw(ioperation_id number,
 2                                  suserid      varchar2) is
 3   scurdjbh yw_operation_link.djbh%type;
 4   cursor table_yw(ywid yw_operation.id%type) is
 5     select * from yw_operation_link t1 where t1.operation_id = ywid;
 6 begin
 7   for dr in table_yw(ioperation_id) loop
 8     scurdjbh := dr.djbh;
 9     --取得opercationid
10     /*   select t1.operation_id
11      into soperationid
12      from yw_operation_link t1
13     where t1.djbh = scurdjbh;*/
14 
15     --写日志
16     insert into log_zfywinfo
17       (djbh,
18        djdl,
19        djxl,
20        dlmc,
21        xlmc,
22        slr,
23        slrid,
24        sqrxm,
25        fwzl,
26        zfrq,
27        zfrid,
28        zfr)
29       select distinct scurdjbh,
30              t4.id,
31              t3.id,
32              t4.name,
33              t3.name,
34              t1.slry,
35              t1.slryid,
36              t1.sqrxm,
37              t1.zl,
38              sysdate,
39              suserid,
40              (select tt.name from pw_user tt where tt.id=suserid)
41         from yw_operation t1
42         join yw_operation_link t2
43           on t2.operation_id = t1.id
44         join business_type t3
45           on t3.id = t1.business_id
46         join business_class t4
47           on t4.id = t3.parent_id
48        where t1.id = dr.operation_id;
49 exception
50   when others then
51     rollback;
52     dbms_output.put_line(sqlerrm);
53 end nw_delyw;

oracle使用cursor 游标循环添加删除更新。

《Oracle游标的简易用法.doc》

下载本文的Word格式文档,以方便收藏与打印。