使用触发器将DB2行复制到历史表(包含XML)

时间:2012-07-13 09:02:10

标签: xml triggers db2

我想将包含XML列的行复制到历史记录表中。似乎不可能这样做?!

我尝试过:

CREATE TRIGGER MARTIN."Pages_I" BEFORE UPDATE OF "tstamp" ON MARTIN."Pages" REFERENCING OLD AS old_row FOR EACH ROW MODE DB2SQL SECURED
INSERT INTO "MARTIN"."HistoryPages" VALUES (old_row."pageId", (SELECT "pageXML" FROM "MARTIN"."Pages" WHERE "pageId" = old_row."pageId" LIMIT 1), old_row."tstamp");

=>由于BEFORE触发器中的INSERT而不允许

CREATE TRIGGER MARTIN."Pages_I" AFTER UPDATE OF "tstamp" ON MARTIN."Pages" REFERENCING OLD AS old_row FOR EACH ROW MODE DB2SQL SECURED
INSERT INTO "MARTIN"."HistoryPages" VALUES (old_row."pageId", old_row."pageXML", old_row."tstamp");

=>不能引用old_row。“pageXML”,因为它是一个xml列

这种困境有没有解决办法?

1 个答案:

答案 0 :(得分:1)

似乎没有解决方案,这只是数据库系统的限制。