1. 程式人生 > >oracle 批量修改

oracle 批量修改

MERGE INTO dms_wl_info a  ----> 目標表 
USING ( SELECT c.position, SUM (c.store_qt) COUNT
FROM dms_goods_stock c
LEFT JOIN sys_office d ON d.id = C.BELONG_DEPARTMENT --> 輔助表(包含目標表需要的資料)
WHERE c.position IS NOT NULL
<if test
="warehouse != null and warehouse != ''">
AND D.PARENT_IDS LIKE '%'||#{warehouse}||'%' --> 動態修改
</if>
GROUP BY c.position) b
ON (a.wl_id = b.position) --> 條件
WHEN MATCHED
THEN
UPDATE SET a.can_save_qt = A.MAX_QT - b.COUNT --> 修改語句,可以插入insert ,輸出結果 output等

 

還有一種批量修改   update_select  語句 參看 

https://www.cnblogs.com/yelanggu/p/6489515.html