我正在使用这种语法
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 DB,而在HANA DB中,普通的SQL触发器查询不是 工作,所以我需要正确的语法,欢迎任何建议 谢谢
答案 0 :(得分: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
;