我有一个使用相关方法的更新查询,如下所示。这需要很长时间才能运行。有没有更好的方法来重写这个。提前感谢您的帮助。
UPDATE DAC A
SET (acc_obj_header,
acc_sub_header,
acc_desc_header
) = (SELECT B.acc_obj,
B.acc_sub,
B.acc_desc
FROM DAC B
WHERE B.country_code = A.country_code
AND B.comp_no = A.comp_no
AND B.bu_no = A.bu_no
AND B.acc_level_of_detail < A.acc_level_of_detail
AND (B.acc_obj || B.acc_sub) = (SELECT MAX(C.acc_obj || C.acc_sub)
FROM DAC C
WHERE C.country_code = A.country_code
AND C.comp_no = A.comp_no
AND C.bu_no =A.bu_no
AND (C.acc_obj || C.acc_sub) <= (A.acc_obj || A.acc_sub)
AND C.acc_level_of_detail < A.acc_level_of_detail
)
AND rownum < 2
)