我有这段代码:
CREATE OR REPLACE TRIGGER avg_elo_trigger
AFTER
INSERT OR DELETE
ON participants_list
BEGIN
UPDATE eventss e2
SET average_elo = (SELECT Round(Avg(p.elo)) FROM participants_list pl
join eventss e on e.event_id = pl.event_id
join players p on p.player_id = pl.player_id
WHERE e.event_id = :P20_EVENT_ID)
WHERE e2.event_id = :P20_EVENT_ID
END;
/
我在第9行收到错误文件结尾,我不知道问题是什么。 BEGIN
和END
之间的代码无法触发。
答案 0 :(得分:1)
你有缺少的分号。
但您也可以简化查询:
import java.time.LocalTime
import org.apache.spark.sql.functions._
def timeOfDay = udf((seconds: Long) => LocalTime.ofSecondOfDay(seconds).toString)
注意:
CREATE OR REPLACE TRIGGER avg_elo_trigger
AFTER INSERT OR DELETE
ON participants_list
BEGIN
UPDATE eventss e
SET average_elo = (SELECT Round(Avg(p.elo))
FROM participants_list pl join
players p
on p.player_id = pl.player_id
WHERE pl.event_id = e.event_id
)
WHERE e2.event_id = :new.P20_EVENT_ID;
END;
表。events
。