Delete row in trigger (PostgreSQL)

I have an update trigger that should delete the OLD * row, but I don't know the table structure. So I tried using information_schema to grab column names, but it is very slow.

Is it possible to perform a deletion without knowing the structure of the tables?

UPD: A trigger must accept a row in any table, so the trigger function cannot know anything about a table before calling it.

UPD2:
This works well for me:

EXECUTE 'DELETE FROM ' || tablename || ' WHERE ctid=$1' USING OLD.ctid;
+3
source share
3 answers

Check out this article:

Dynamic triggers in PLpgSQL

+1
source

? , . , , .

+1

You can describe the table in postgre sql using \d+ tablename.

0
source

Source: https://habr.com/ru/post/1777385/


All Articles