[英]DB2 SQL instead of update trigger
Hi I have the following code, for create a DB2 SQL trigger, extended 嗨,我有以下代码,用于创建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
@
I run this script with this: db2 -td@ -v -f trig_ipd_wiev1.db2 -z procs.log
我使用以下命令运行此脚本:
db2 -td@ -v -f trig_ipd_wiev1.db2 -z procs.log
----PROBLEM SOLVED---- - - 问题解决了 - -
The problem was, that, there was SET c.region = n.region WHERE c.region = o.region;
问题是,有
SET c.region = n.region WHERE c.region = o.region;
instead of SET c.region = n.continent WHERE c.region = o.continent;
而不是
SET c.region = n.continent WHERE c.region = o.continent;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.