Well I am trying to create a trigger, but it seems that using PGMyadmin’s SQL command prompt wont work, it shows syntax error all the time:
CREATE TRIGGER trigger_name BEFORE INSERT ON table_name
FOR EACH ROW
BEGIN
// Code inside
END;
Anyone knows how to fix this problem? I have absolutely no idea why this syntax error appears:
ERROR: syntax error at or near “BEGIN”
LINE 3: BEGIN
^
r937
September 16, 2013, 11:37am
2
i would start by looking up the CREATE TRIGGER syntax in da manual –
Yeah I made sure to check the syntax and found nothing wrong with it.
cpradio
September 16, 2013, 12:54pm
4
From the manual, it seems a TRIGGER can ONLY execute a function in PostgresSQL
CREATE TRIGGER creates a new trigger. The trigger will be associated with the specified table and will execute the specified function funcname when certain events occur.
Well the Manual says that its possible to use FOR EACH ROW statement, weird.
cpradio
September 16, 2013, 1:07pm
6
Yes, but following that must be EXECUTE funcname (arguments) not BEGIN