Retrieve updated rows in AFTER UPDATE trigger Postgresql

225 Views Asked by At

I'm writing a AFTER UPDATE trigger in postgresql.

Actualy I need to get at least one row after update in STATEMENT LEVEL trigger, but there is no OLD or NEW variable there.

In FOR EACH ROW trigger I didn't manage to find a sort of batch_last param. But to do my procedure FOR EACH ROW is expensive.

How can I do this?

1

There are 1 best solutions below

2
On BEST ANSWER

You can create a temporary table (so that it will visible only in the session). In the row level trigger you insert the rows into the temporary table, in the statement level trigger you select (and delete) from the temporary table.