1

我必须从选择中进行更新,我得到了这 2 个包含这些行的表

T1

customer_number | trx number     | amount_due_remaining
____________________________________________________
309514          |MM1218881/2011  | 0
309514          |MM1218882/2011  | 0
309514          |MM1218903/2011  | 0
309514          |MM1218905/2011  | 0

T2

contract | numdoc         | import
___________________________________
309514 |MM1218881/2011  | 2000,77
309514 |MM1218882/2011  | 1000,45
309514 |MM1218903/2011  | 1000,23
309514 |MM1218905/2011  | 2500,12

我必须将列 amount_due_remaining 的 T1 的值放入 T2 导入

我做这个查询

update dbestrconto T1
SET T1.IMPORTO = (
SELECT nvl(T2.AMOUNT_DUE_REMAINING,0)
FROM XXENE_V_CCML_TRANSACTIONS@XXENE T2
WHERE T2.customer_number=T1.contratto
AND T2.customer_number='3095614'
and T2.TRX_NUMBER=T1.NUMDOC
)

但是错了,请帮帮我。

问候, 鲁道夫

4

1 回答 1

0

您正在更新所有行 - 您需要在 UPDATE 中添加 where 子句。

我建议改用 MERGE。

merge into dbestrconto  t1 
using xxene_v_ccml_transactions@xxene t2
on  (t2.customer_number=t1.contratto
and t2.trx_number=t1.numdoc)
when matched then update set 
    t1.importo = nvl(t2.amount_due_remaining,0)
where  t2.customer_number='3095614';

问候。霸气。

于 2013-02-15T13:11:55.017 回答