Re: Trigger functions with dynamic SQL

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Trigger functions with dynamic SQL
Дата
Msg-id 4370.1090681307@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Trigger functions with dynamic SQL  (Andreas Haumer <andreas@xss.co.at>)
Ответы Re: Trigger functions with dynamic SQL
Список pgsql-sql
Andreas Haumer <andreas@xss.co.at> writes:
> It seems I would have to use EXECUTE on dynamically constructed
> PL/PGSQL statements in order to have my trigger function recognize
> the parameters given to the trigger in TG_ARGV[]

Yup, that's exactly right.  plpgsql isn't designed for this; it's
designed for situations where it can pre-plan and cache plans for
queries, and dynamically-inserted table and column names would just
break that completely.  So you have to fall back to the mechanisms
for fully general constructed-on-the-fly queries, which work but
are a bit painful to use.

You might want to look at pltcl instead, which is much friendlier
to dynamically generated queries (since that's the only way it
does things).  Of course, if you've never used Tcl there'll be
a bit of a learning curve :-(
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Is a backend id or something available for use as a foreign key?
Следующее
От: Andreas Haumer
Дата:
Сообщение: Re: Trigger functions with dynamic SQL