简体   繁体   中英

Syntax error on an INSTEAD OF TRIGGER CREATION - PostgresSQL

I'm trying to create an INSTEAD OF TRIGGER following the Postgres documentation, but there's a syntax error that I can't find the exact error location.

    CREATE TRIGGER TRUpdateRuntime 
        INSTEAD OF UPDATE ON Papeis
        FOR EACH ROW
        REFERENCING NEW ROW AS N
        UPDATE Movies SET RunTime=N.RunTime WHERE MovieId=Papeis.MovieId

I have created the Papeis View before the trigger creation and it keeps bringing this error:

syntax error at or near "REFERENCING"

Cannot be used with INSTEAD OF trigger. See:

https://www.postgresql.org/docs/current/sql-createtrigger.html

"This option is only allowed for an AFTER trigger that is not a constraint trigger; ..."

Adrian's answer is right.

But the immediate cause of the syntax error is that the REFERENCING clause must come before the FOR EACH clause.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM