Re: Dynamically accessing columns from a row type in a trigger

Поиск
Список
Период
Сортировка
От Rhys A.D. Stewart
Тема Re: Dynamically accessing columns from a row type in a trigger
Дата
Msg-id CACg0vT=ELyfN5NEdp001TkJQxKyoxAAyUPwMmY_d+xYBHYMRtg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Dynamically accessing columns from a row type in a trigger  (jian he <jian.universality@gmail.com>)
Ответы Re: Dynamically accessing columns from a row type in a trigger
Список pgsql-general
Hello again



> > Actually, now that I'm thinking about it, I don't really want to store
> > the value into a variable because the pk_col might be of any given
> > type. So ideally, I'd love a way to just get the value from OLD and
> > use it directly in another query. Something along the lines of:
> >
> > `EXECUTE format('SELECT * FROM %1$I.sometable WHERE pk = $1', myschma)
> > USING OLD['pk_col']`.
> >
> > I reckon I may have to look at just generating a trigger function per
> > table, or maybe look into using TG_ARGS.



So the less obvious solution that works is to create a temporary
table. A little verbose, but I get to keep the types.

`CREATE TEMPORARY TABLE _ ON COMMIT DROP AS SELECT OLD.*;`

_ as a table name makes things a little easier to type.



Rhys
Peace & Love | Live Long & Prosper



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

Предыдущее
От: Ron
Дата:
Сообщение: Re: Fatal Error : Invalid Memory alloc request size 1236252631
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: Dynamically accessing columns from a row type in a trigger