Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-16 Thread Sylvain Mougenot
It works with the answer suggested by Jasen Betts EXECUTE 'INSERT INTO '|| currentTableName || ' values ($1.*)' USING NEW; Thank you all for all the help, and special thanks to Josh Kupershmidt and Jasen Betts (in the order I received messages) The full code is --- SQL --

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-12 Thread Jasen Betts
On 2011-11-08, Sylvain Mougenot 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 cre

[SQL] Partitionning + Trigger and Execute not working as expected

2011-11-10 Thread Sylvain Mougenot
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-p

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-09 Thread Josh Kupershmidt
On Wed, Nov 9, 2011 at 4:39 PM, Sylvain Mougenot wrote: > As I mentioned before, your code works on special cases (insert with all the > columns) and those are very few cases. > Try this > CREATE TABLE foo (a int, b int); > CREATE TABLE job_2011_11 (c int, d int); > > CREATE OR REPLACE FUNCTION jo

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-09 Thread Sylvain Mougenot
As I mentioned before, your code works on special cases (insert with all the columns) and those are very few cases. Try this CREATE TABLE foo (a int, b int); CREATE TABLE job_2011_11 (c int, d int); CREATE OR REPLACE FUNCTION job_insert_trigger() RETURNS TRIGGER AS $BODY$ DECLARE currentT

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-09 Thread Josh Kupershmidt
On Wed, Nov 9, 2011 at 6:57 AM, Sylvain Mougenot wrote: > Even if the query below is fine (the exact content I try to build as a > String to use with EXECUTE) > INSERT INTO job_2011_11 values (NEW.*) > Is there a way to solve this? > Isn't it a bug (in how EXECUTE works)? I doubt this is a bug i

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-09 Thread Sylvain Mougenot
Thank you for the help. But it doesn't work : EXECUTE 'INSERT INTO '|| currentTableName || ' values ' || (NEW.*); QUERY: INSERT INTO job_2011_11 values (117916386,-5,,2,2,11,1,,00,"2011-11-07 00:00:00","2011-11-07 00:00:00",,0,0,,0) CONTEXT: PL/pgSQL function "job_insert_trigger" line

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-08 Thread Josh Kupershmidt
On Tue, Nov 8, 2011 at 11:04 AM, Sylvain Mougenot wrote: > EXECUTE 'INSERT INTO '|| currentTableName || ' values (NEW.*)'; The quotes in the above line are wrong; you want it like: EXECUTE 'INSERT INTO '|| currentTableName || ' values ' || (NEW.*); Josh -- Sent via pgsql-sql mailing list (pgs

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-08 Thread Sylvain Mougenot
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-p