pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: Partitionning + Trigger and Execute not working as expected
Date: 12 Nov 2011 09:56:02 GMT
Message-ID: <j9lfri$i5m$1@reversiblemaps.ath.cx> (raw)
References: <CACKdPFikHUzyD2+eKhQRg-aVtL+is9uUzkBRCP+txhK=nURW_w@mail.gmail.com>

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




view thread (9+ messages)  latest in thread

Message-ID: <j9lfri$i5m$1@reversiblemaps.ath.cx>
Permalink:  ../j9lfri$i5m$1@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/j9lfri$i5m$1@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasen@xnet.co.nz
  Subject: Re: Partitionning + Trigger and Execute not working as expected
  In-Reply-To: <j9lfri$i5m$1@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox