我有一个用于更新数据的SQL查询:
UPDATE (
SELECT
cal.year_no,
pi.bin,
pi.tin,
epa.fc_fc_id,
epa.ec_ec_id,
NVL(epa.COMMIT_OBLIGATION, 0) as pay_amount,
cal.month_no as months,
EPA.PAY_AMOUNT_MONTH,
EPA.PAY_AMOUNT_CALC_DATE
FROM
summary_of_expenditures epa
INNER JOIN calendar cal ON (epa.cal_cal_id_pay = cal.cal_id)
INNER JOIN public_institution pi ON (epa.pi_pi_id = pi.pi_id)
WHERE (
(epa.fc_fc_id is not null)
AND (epa.ec_ec_id is not null)
AND (cal.month_no IN ('11'))
)
GROUP BY
cal.year_no,
cal.month_no,
epa.COMMIT_OBLIGATION,
pi.bin,
pi.tin,
epa.fc_fc_id,
epa.ec_ec_id,
EPA.PAY_AMOUNT_MONTH,
EPA.PAY_AMOUNT_CALC_DATE)
SET
PAY_AMOUNT_MONTH = pay_amount,
PAY_AMOUNT_CALC_DATE = SYSDATE;
当我执行它时,我有一个跟随例外:
SQL Error: ORA-01732: data manipulation operation not legal on this view.
请告诉我,我做错了什么,或建议我更新数据的方法。
答案 0 :(得分:1)
您不能在相关更新语句中使用GROUP BY,因为这会生成视图。