如何在sap hana sql触发器中获取最后一行?

时间:2015-05-25 08:04:45

标签: sql triggers hana

我在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触发器似乎不支持。

帮助!

1 个答案:

答案 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;