文件结束触发错误

时间:2018-05-30 00:13:59

标签: sql oracle plsql triggers

我有这段代码:

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行收到错误文件结尾,我不知道问题是什么。 BEGINEND之间的代码无法触发。

1 个答案:

答案 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
  • 相关性可以是外表,而不是重复常量。