I want to create a trigger to concatenate my column with event "before insert", but the query didn't work and i got an error:
SQL error:
ERROR: syntax error at or near "SET" LINE 4: SET new.fullname = CONCAT(new.first_name, '', new.mid_name, ...
In statement:
CREATE TRIGGER insert_trigger
BEFORE INSERT ON t_employees
FOR EACH ROW
SET new.fullname = CONCAT(new.first_name, '', new.mid_name, '', new.last_name);
Here's a working solution:
Well, i finally did it. According your suggestions and postgresql docs i've made the trigger like what i want. Here is the syntax:
create the function:
then create the trigger: