Oracle多表级联更新详解
发布时间:2020-12-12 16:56:04 所属栏目:百科 来源:网络整理
导读:用游标实现,我觉得绝对这种方法比较安全的。 代码如下:declare CURSOR D_CURSOR_CUS_INFO IS select t3.id_ as id_, t3.owe_money_ as owe_money_, a.heatingArea as heating_area_ from T_CUS_OWE_MONEY_2 t2 left join T_CUS_OWE_MONEY_3 t3 on t2.id_= t
用游标实现,我觉得绝对这种方法比较安全的。 代码如下:declare CURSOR D_CURSOR_CUS_INFO IS select t3.id_ as id_, t3.owe_money_ as owe_money_, a.heatingArea as heating_area_ from T_CUS_OWE_MONEY_2 t2 left join T_CUS_OWE_MONEY_3 t3 on t2.id_= t3.id_ left join (select s.bh,sum( case when s.stkbz='0' then nvl(s.mj,0) when s.stkbz='1' then 0-nvl(s.mj,0) end ) as heatingArea from sk s where s.nd = '2008-2009' group by s.bh) a on t2.bh_=a.bh where t3.owe_money_- t2.owe_money_ = a.heatingArea*5 and t3.OWE_MONEY_ > 0; 代码如下:begin FOR everyRow IN D_CURSOR_CUS_INFO loop update T_CUS_YEAR_STATUS t set t.HEATING_AREA_ = everyRow.HEATING_AREA_, t.OWE_MONEY_ = everyRow.owe_money_ where t.YEAR_ = '2008-2009' and t.id_ = everyRow.id_; end loop; commit; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby – 将UTF-8设置为Heroku中的默认字符串编码
- ruby-on-rails – 如何为“编辑”路径创建Cucumber步骤定义
- u-boot1.1.6在NorFlash下启动后实现对Nand的操作(开发用的
- 【Cocos2d入门教程一】Cocos2d下安卓环境的搭建
- c# – 如何获取字典中键的ReadOnlyCollection
- cocos2d-x 3.6版loading加载资源
- ruby-on-rails – 如何在Rails 4中设置自定义字符串外键?
- Oracle 使用concat函数需要注意的地方
- ruby-on-rails – 使用Active Merchant和PayPal时出现SSL错
- 如何在Ruby中对浮点数组进行排序?