I have a complex trigger which executes on update of a table.
I get what I want when I execute it's body with 'new table' replaced with existing table, but it messes things up when it called by update.
I want to debug this and I want to start by viewing what my trigger gets as 'new table'. How can I look on it?
CREATE TRIGGER foo_trigger AFTER
UPDATE
ON
public.table1 REFERENCING NEW TABLE AS new_table FOR EACH STATEMENT EXECUTE FUNCTION foo()
CREATE OR REPLACE FUNCTION public.foo()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
*do things with new_table*
RETURN NULL;
END;
$function$
;
NEWisn't the entire new table, it's the new records coming in. You can create a mirror table where you dump it:create table public.foo_trigger_test as table public.table1 with no data;then, in the trigger function:insert into public.foo_trigger_test select * from new_table;not about debug my code for meand mean that I just needed to know a way to copy this new_table somewhere I can read it from. And your code works, thanks!