SQL TRIGGERS编译错误(SQL TRIGGERS compilation errors)

我在这做错了什么? 我一直在用我的触发器收到警告信息

CREATE TRIGGER DateFinDebut AFTER INSERT OR UPDATE OF dateFin ON SessionUQAM FOR EACH ROW BEGIN dateFin = DATEADD(day,90,dateDebut); END; / Warning: Trigger created with compilation errors.

What am I doing wrong here? I keep getting warning messages with my triggers

CREATE TRIGGER DateFinDebut AFTER INSERT OR UPDATE OF dateFin ON SessionUQAM FOR EACH ROW BEGIN dateFin = DATEADD(day,90,dateDebut); END; / Warning: Trigger created with compilation errors.

最满意答案

我正在猜测

dateFin = DATEADD(day,90,dateDebut);

旨在将90天添加到当前行的datedebut值。

在Oracle中没有dateadd函数。 您只需在日期中添加若干天。 在触发器中,您需要使用:new伪记录来引用当前行。

:new.datefin := :new.datedebut +90;

您可以使用show errors列出SQL * Plus中的编译错误,尽管SQL Developer (免费)和PL / SQL Developer (商业)等工具会以交互方式列出它们。

I'm guessing

dateFin = DATEADD(day,90,dateDebut);

is intended to add 90 days to the current row's datedebut value.

In Oracle there is no dateadd function. You just add a number of days to a date. In a trigger you need to refer to the current row using the :new pseudo-record.

:new.datefin := :new.datedebut +90;

You can list compilation errors in SQL*Plus using show errors, although tools such as SQL Developer (free) and PL/SQL Developer (commercial) will list them more interactively.

更多推荐