oracle执行比较大的存储过程中,同一个表,同一组数据,执行完UPDATE语句操作,并commit以后,紧接着执行MERGE INTO 语句时,会出现上面的UPDATE语句锁表的问题:
UPDATE PB_BALANCE_ACCOUNT_DTL T SET T.ENDCOST = NVL(T.BEGINCOST,0)+NVL(T.CURRENTCOST,0)
WHERE T.CORPORATION=corp AND T.FARM=fa AND T.MONTH=mon AND T.COSTSTATUS=0;
COMMIT;
-----
MERGE INTO PB_BALANCE_ACCOUNT_DTL T1
USING(
SELECT T.PID,T.COSTTYPE,T.ENDCOST ECOST,T.PPH FROM PB_BALANCE_ACCOUNT_DTL T WHERE T.COSTSTATUS=0 AND T.CORPORATION=corp AND T.FARM=fa AND T.MONTH=mon
)T2 ON(T1.PID=T2.PID AND T1.COSTTYPE=T2.COSTTYPE AND T1.CORPORATION=corp AND T1.FARM=fa AND T1.MONTH=mon AND T1.PPH=T2.PPH+1)
WHEN MATCHED THEN
UPDATE SET T1.BEGINCOST=T2.ECOST;
COMMIT;
上面两句语句,执行的是同一个表数据,第一句执行完update以后并commit;然后执行第二句merge into时,会锁定第一句update语句,造成表PB_BALANCE_ACCOUNT_DTL锁表;请oracle大神能江湖救急。