

update ARCHIVE_FRONT af
set    af.TRANSFER_AMOUNT = (select coalesce((select sum(tl.TRANSFER_AMOUNT)
                                              from   EAI_P2F_TRANSFER_LOG tl
                                              where  tl.ID_SMETKA_PAYMENT = ap.ID_SMETKA_PAYMENT),
                                             ap.PAYMENT_VALUE)
                             from   ARCHIVE_PAYMENT ap
                             where  ap.ID_SMETKA_FRONT = af.ID_SMETKA_FRONT)
where  af.TRANSFER_AMOUNT is null;

