我必须从选择中进行更新我得到了这个带有这行的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
我必须在T2中将值amount_due_remaining的T1的值放入导入
我做这个查询
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
)
但是错了,请帮助我。
此致,Rodolfo
答案 0 :(得分:0)
您正在更新所有行 - 您需要向您添加一个where子句UPDATE。
我建议改用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';
的问候。 HAKI。