update account_money set account_money.ssye = (SELECT account_money.ssye + fund_apply_original_return.authorize_pay
from fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0')
from fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0')
update account_money set account_money.ssye = (SELECT account_money.ssye + fund_apply_original_return.authorize_pay
from fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0'));
多谢你,可是我要修改的是很多字段,如下
update account_money set
account_money.ssye = account_money.ssye+fund_apply_original_return.authorize_pay,
account_money.column2 = account_money.column2 + fund_apply_original_return.column2
.......
from account_money,fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0')
这样该如何写呢?
update account_money set (account_money.ssye,account_money.xxx) = (SELECT account_money.ssye + fund_apply_original_return.authorize_pay,
account_money.xxx + fund_apply_original_return.yyy
from fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0'));
from fund_apply_original_return
where account_money.year = fund_apply_original_return.year and
account_money.unit_code = fund_apply_original_return.budget_unit and
account_money.subject_code = fund_apply_original_return.subject_code and
account_money.item_code = nvl(fund_apply_original_return.item_code,'0'));
而是对于某一行执行更新的时候,检索出多行符合条件的数据,系统当然就无法进行更新了。
加上MAX(),MIN(),AVG等函数可以解决,但不推荐,因为是数据的对应关系有问题!