Re: Partitionning + Trigger and Execute not working as expected

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Partitionning + Trigger and Execute not working as expected
Дата
Msg-id j9lfri$i5m$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Partitionning + Trigger and Execute not working as expected  (Sylvain Mougenot <smougenot@sqli.com>)
Список pgsql-sql
On 2011-11-08, Sylvain Mougenot <smougenot@sqli.com> wrote:
> --f46d043c7fbad4a6b104b1357041
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> Hello,
> I'm trying to use table partitionning on a table called JOB.
> Each month a new table is created to contain the rows created on that month=
> .
> ex : JOB_2011_11 for rows created during november 2011.
>
> To do that I followed this advices on that page :
> http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html
> I also would like to create code dynamically into the trigger in order to
> have all "INSERT INTO" inheritated tables (tables like JOB_YYYY_MM) queries
> done.
>
> But I can't make it work. I've an error when the insert is done using
> EXECUTE.
> *Working :* INSERT INTO job_2011_11 values (NEW.*);
> *Not Woking : *EXECUTE 'INSERT INTO '|| currentTableName || ' values
> (NEW.*)';
>
> Could someone tell me how to make this EXECUTE work?

EXECUTE 'INSERT INTO '|| currentTableName || ' select ('||quote_literal(NEW)||'::job%ROWTYPE).*';

or

EXECUTE 'INSERT INTO '|| currentTableName || ' values ($1.*)' USING NEW;


-- 
⚂⚃ 100% natural



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

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: clarification about ARRAY constructor implementation
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Updatable view should truncate table fields