本帖最后由 oracle-admin 于 2014-1-22 16:17 编辑
我现在有一条多表关联的更新数据的sql语句,例如:
merge into tbl_ticketorder a
using (select ticketorder_id, newtourcode --, ticketno
from (select /*+ use_nl(s,t1) use_nl(t1,t2) use_nl(t2,t3) use_nl(t3,t4)*/
--t1.rowid as rid,
t1.ticketorder_id,
s.newtourcode,
t3.ticketno,
row_number() over(partition by t3.ticketno order by t1.ticketorder_id desc) as seq
from tmp_settleCenterPricing s,
tbl_ticketorder t1,
tbl_passenger t2,
tbl_orderprice
t3,
tbl_orderstatus t4
where t1.ticketorder_id = t2.orderid
and t2.passenger_id = t3.ORDERPRICE_ID
and t3.ticketno = t4.orderstatus_id
and s.fullticketno = t3.ticketno
and t1.status = 1
and t1.orderstate = 4)
where seq = 1) b
on (a.ticketorder_id = b.ticketorder_id)
when matched then
update set a.tourcode = b.newtourcode
QQ图片20140122160337.jpg (40.73 KB, 下载次数: 6)
下载附件
需要更新的数据的样例
2014-1-22 16:06 上传
现在有一个问题,比如更新999-2143276317的时候更新id为5082对应的值,但是再更新999-2143276319这个的时候,发现对应的id也是5082,由于是批量更新前一个没提交,下一个肯定无法更新了,结果就会报如下错误ORA-30926: unable to get a stable set of rows in the source tables
请问针对如上问题,该如何处理?是否只能通过游标循环,一条条的去更新并提交?不知是否有其他方法,请各位高手赐教!
要求是:在更新999-2143276317的时候,先更新一遍5082对应的值,提交;再接着更新999-2143276319对应的值,虽然还是5082对应的值,但是就把上一次更新的结果给再更新一遍,相当于覆盖了。后面的ticketno的值如果对应的还有相同的ticketorder_id的话,依次按照上面的方法去覆盖更新。
|