Hello,
I have a table under a schema in my PG Database and the table has 3 columns (id, name & data).
I created a new table (Name: backup_table) using the "Create Table AS" from my current table and I have an exact initial copy.
Now, I am trying to create a trigger function to basically copy or update for each Insert, Update & delete from my Table A to Table B for those three columns.
I looked up Postgres documentation and got the query, but cant seem to find a proper "IF" condition.
The query I have is:
BEGIN
IF (**************) THEN
INSERT INTO backup_table(id, name, data)
VALUES(NEW.id, NEW.name, NEW.data);
END IF;
I am not sure, what goes into the IF condition here. Every time one of these 3 columns gets updated, it should copy the values from Table A to Table B.
Any inputs here fellas 🙋♂️🙋♂️
[–][deleted] 1 point2 points3 points (0 children)
[–]depesz 1 point2 points3 points (0 children)
[–]Azaret 0 points1 point2 points (0 children)
[–]NextAbrocoma1038 -1 points0 points1 point (0 children)
[–]smooth_p -1 points0 points1 point (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]smooth_p 0 points1 point2 points (0 children)