Re: Partitionning + Trigger and Execute not working as expected - Mailing list pgsql-sql

From Sylvain Mougenot
Subject Re: Partitionning + Trigger and Execute not working as expected
Date
Msg-id CACKdPFgTuvUFHoG-qhZh3UZY=JG8M5eMnL_q2gmWK_nh2xWoAg@mail.gmail.com
Whole thread Raw
In response to Re: Partitionning + Trigger and Execute not working as expected  (Josh Kupershmidt <schmiddy@gmail.com>)
Responses Re: Partitionning + Trigger and Execute not working as expected  (Josh Kupershmidt <schmiddy@gmail.com>)
List pgsql-sql
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,1,,,,1,1,,0,,,,,,,,0,"2011-11-07 00:00:00","2011-11-07 00:00:00",,0,0,,0)
CONTEXT:  PL/pgSQL function "job_insert_trigger" line 9 at instruction EXECUTE

It looks like the NULL values are blanks in the generated query. 


Using the query below produces an error too
EXECUTE 'INSERT INTO '|| currentTableName || ' values (NEW.*)';
ERREUR: missing FROM clause for table « new »
SQL :42P01
QUERY:  INSERT INTO job_2011_11 values (NEW.*)
CONTEXT:  PL/pgSQL function "job_insert_trigger" line 9 at instruction EXECUTE


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)?

On Wed, Nov 9, 2011 at 1:35 AM, Josh Kupershmidt <schmiddy@gmail.com> wrote:
On Tue, Nov 8, 2011 at 11:04 AM, Sylvain Mougenot <smougenot@sqli.com> 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



--
Sylvain Mougenot


pgsql-sql by date:

Previous
From: tlund79
Date:
Subject: Re: Issue with a variable in a function
Next
From: Josh Kupershmidt
Date:
Subject: Re: Partitionning + Trigger and Execute not working as expected