Using a cursor, I think this method is absolutely safe.
-- First, set a cursor to store the required data in the cursor:
Copy codeThe Code is as follows:
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 = '2017-2008 '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;
-- Then the cyclic cursor updates the data:
Copy codeThe Code is as follows:
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 _ = '2017-2008'
And t. id _ = everyRow. id _;
End loop;
Commit;
End;