oracle中update时要注意加where exists判断,如:
update
sysmanage.tmp_p8030009 a
set a.today_stockvalue = ( select ta.stockvalue_rmb
from ( select account_id,
sum (stockvalue_rmb) as stockvalue_rmb
from olap.tb_inn_stk_bal_cur_month
where occur_date = i_startdate
group by account_id ) ta
where ta.account_id = a.account_id)
where exists ( select 1 from ( select account_id,
sum (stockvalue_rmb) as stockvalue_rmb
from olap.tb_inn_stk_bal_cur_month
where occur_date = i_startdate
group by account_id ) ta
where ta.account_id = a.account_id);
或者把exists条件改为in都可以, where a.account_id in (...).
set a.today_stockvalue = ( select ta.stockvalue_rmb
from ( select account_id,
sum (stockvalue_rmb) as stockvalue_rmb
from olap.tb_inn_stk_bal_cur_month
where occur_date = i_startdate
group by account_id ) ta
where ta.account_id = a.account_id)
where exists ( select 1 from ( select account_id,
sum (stockvalue_rmb) as stockvalue_rmb
from olap.tb_inn_stk_bal_cur_month
where occur_date = i_startdate
group by account_id ) ta
where ta.account_id = a.account_id);
或者把exists条件改为in都可以, where a.account_id in (...).