0

I am working in PGAdmin4, learning postgresql (yes, I am still green to this), and trying to build a trigger for a project.

Everything seems to be working well until I get to the create trigger:

CREATE OR REPLACE TRIGGER Mail_List_upd 
BEFORE UPDATE
ON Mail_List
FOR EACH ROW
EXECUTE PROCEDURE Mail_List_upd_func();

When I execute this, in addition to the rest of my code, I get the following error:

ERROR:  syntax error at or near "CREATE"
LINE 73: CREATE OR REPLACE TRIGGER Mail_List_upd
         ^
SQL state: 42601
Character: 1824

I have gone through all the work and everything looks good. I as curious if this might be a dialect issue, but that does not seem to be it. I looked up another person's work on github and tried it and saw the same error. So I am at a loss.

  • Are you sure you are using Postgres **14**? What does `select version();` show you? –  Mar 21 '22 at 14:15
  • "PostgreSQL 14.2, compiled by Visual C++ build 1914, 64-bit" – Samuel Wright Mar 21 '22 at 14:29
  • 1
    Do you have any other statements in the SQL editor? Then maybe you forgot to end the previous one with `;` The statement as shown [is valid](https://dbfiddle.uk/?rdbms=postgres_14&fiddle=bd9d391c0ff707a6f501c058d93691aa) –  Mar 21 '22 at 14:29
  • Thanks... makes me feel a little better about the work, now I will go back through the rest of my code and make sure that I did not forget something. are there any "quick and dirty" rules to follow to know what does and does not need the terminator ";" at the end of it? – Samuel Wright Mar 21 '22 at 14:45
  • @a_horse_with_no_name - Thanks... and sorry for the delay. Hell being a student, working full-time, and with a kid in Young Marines. :-) I was able to find a section that was missing the ";" and that did correct it. In fact, there were two missing. How do I mark you answer as the one that helped so you get the win? :-) – Samuel Wright Mar 28 '22 at 04:56

0 Answers0