我在SAP HANA中创建了这个sql触发器,无法找出如何引用最后插入的行,这里是触发器的代码:
CREATE TRIGGER MY_TRIGGER
AFTER INSERT ON TARGET_TABLE
FOR EACH ROW
BEGIN
CALL SOME_PROCEDURE(:NEWROW.id);
END;
我尝试了REFERENCING NEW ROW
语法,但INSERT AFTER
触发器似乎不支持。
帮助!
答案 0 :(得分:1)
CREATE TRIGGER TEST_TRIGGER_VAR_UPDATE
AFTER UPDATE ON TARGET
REFERENCING NEW ROW mynewrow, OLD ROW myoldrow
FOR EACH ROW
BEGIN
INSERT INTO SAMPLE_new VALUES(:mynewrow.a, :mynewrow.b);
INSERT INTO SAMPLE_old VALUES(:myoldrow.a, :myoldrow.b);
INSERT INTO SAMPLE VALUES(0, 'trigger');
END;