Skip to content
Advertisement

PostgreSQL: Trigger INSERT INTO SELECT from other table

I’m trying to create a trigger that will add a new row processed entry to a destination table each time a new row is created in the source table.

Step 1 Create destination table:

Step 2 Create trigger function:

** The Select query inside function work normally when single running.

Step 3 Create trigger:

The problem is that Trigger does not work, which means it does not record new entries in the target table. Can’t figure out where the error is.

Advertisement

Answer

You should be using the NEW record in the trigger function to reference the newly inserted data instead of a select, i.e.:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement