您好我有以下代码,用于创建DB2 SQL触发器,扩展
connect to sample
@
drop TABLE countries
@
drop view view1
@
drop TRIGGER update_view1_2
@
CREATE TABLE countries (id int, country varchar(50), region varchar (50), average_temp int)
@
CREATE VIEW view1 (id, continent, temperature) as SELECT id, region, average_temp from countries
@
CREATE TRIGGER update_view1_2
INSTEAD OF UPDATE ON view1
REFERENCING OLD AS o NEW AS n
FOR EACH ROW
MODE DB2SQL
BEGIN ATOMIC
UPDATE countries c
SET c.region = n.continent
WHERE c.region = o.continent;
END
@
我用这个运行这个脚本:
db2 -td@ -v -f trig_ipd_wiev1.db2 -z procs.log
----问题已解决----
答案 0 :(得分:0)
问题在于,有
SET c.region = n.region
WHERE c.region = o.region;
代替
SET c.region = n.continent
WHERE c.region = o.continent;