在HANA DB中创建“而不是插入”触发器的语法

问题描述 投票:0回答:1

我正在使用这种语法

CREATE TRIGGER tgBook 
INSTEAD OF INSERT ON "SYSTEM"."BOOK"
FOR EACH ROW
BEGIN
INSERT INTO "SYSTEM"."CLASSA" (rollNo, name, percentage)
SELECT rollNo, name, percentage
FROM INSERTED
INSERT INTO "SYSTEM"."ClassB" (english, maths)
SELECT english, maths
FROM INSERTED
END

我收到了这个错误

Could not execute 'CREATE TRIGGER tgBook INSTEAD OF INSERT ON "SYSTEM"."BOOK" FOR EACH ROW BEGIN INSERT INTO ...'
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "INTO": line 8 col 8 (at pos 206)

我正在使用HANA数据库并且在HANA数据库中正常的SQL触发器查询不起作用所以我需要正确的语法欢迎任何建议谢谢

hibernate hana
1个回答
0
投票

我得到的解决方案实际上语法是错误的。实际的语法是

CREATE TRIGGER "SYSTEM"."tgBook" INSTEAD OF INSERT ON "SYSTEM"."BOOK" REFERENCING NEW ROW NEW FOR EACH ROW 
BEGIN INSERT 
INTO ClassA (rollNo,
    name,
    percentage) VALUES(:NEW.rollNo,
     :NEW.name,
     :NEW.percentage)
;
 INSERT 
INTO ClassB (rollNo,
    english,
    maths) VALUES(:NEW.rollNo,
     :NEW.english,
     :NEW.maths)
;

END
;
© www.soinside.com 2019 - 2024. All rights reserved.