Re: [GENERAL] dynamic insert in plpgsql

2010-01-09 Thread Grzegorz Jaśkiewicz
This is what I hacked quickly last night, what you guys think? CREATE OR REPLACE FUNCTION something.ziew_partition_insert() RETURNS TRIGGER AS $_$ DECLARE partition_table_name varchar; old_partition_table_name varchar; BEGIN SELECT 'something_partitions.ziew_'||to_char(NEW.logtime, 'IYYY_MM

Re: [GENERAL] dynamic insert in plpgsql

2010-01-09 Thread Merlin Moncure
2010/1/9 Dimitri Fontaine : > Grzegorz Jaśkiewicz writes: > >> Is there any nice way to do something like that in plpgsql: >> >>   EXECUTE 'INSERT INTO '||partition_table_name||' VALUES'||(NEW.*)||''; > > See http://wiki.postgresql.org/wiki/PL/pgSQL_Dynamic_Triggers > -- that approach is awful.

Re: [GENERAL] dynamic insert in plpgsql

2010-01-09 Thread Dimitri Fontaine
Grzegorz Jaśkiewicz writes: > Is there any nice way to do something like that in plpgsql: > > EXECUTE 'INSERT INTO '||partition_table_name||' VALUES'||(NEW.*)||''; See http://wiki.postgresql.org/wiki/PL/pgSQL_Dynamic_Triggers -- dim -- Sent via pgsql-general mailing list (pgsql-general@post

Re: [GENERAL] dynamic insert in plpgsql

2010-01-08 Thread Grzegorz Jaśkiewicz
2010/1/8 Grzegorz Jaśkiewicz : > what is that "(t" in the SELECT there for ? > or is it just typo, or something missing/etc ? > ignore it. That's cast, for type t (table). -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http:/

Re: [GENERAL] dynamic insert in plpgsql

2010-01-08 Thread Grzegorz Jaśkiewicz
what is that "(t" in the SELECT there for ? or is it just typo, or something missing/etc ? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] dynamic insert in plpgsql

2010-01-08 Thread Grzegorz Jaśkiewicz
On Fri, Jan 8, 2010 at 2:58 PM, Sam Mason wrote: > Yup, this thing is a bit fiddly.  Try: > >  http://archives.postgresql.org/pgsql-general/2009-09/msg01176.php I searched for it, but didn't stumble upon that one. Thanks. -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgres

Re: [GENERAL] dynamic insert in plpgsql

2010-01-08 Thread Sam Mason
On Fri, Jan 08, 2010 at 02:55:53PM +, Grzegorz Jaaakiewicz wrote: > Is there any nice way to do something like that in plpgsql: > > EXECUTE 'INSERT INTO '||partition_table_name||' VALUES'||(NEW.*)||''; > > It would probably work, but some values are NULL, and plpgsql > interpreter just puts

[GENERAL] dynamic insert in plpgsql

2010-01-08 Thread Grzegorz Jaśkiewicz
Is there any nice way to do something like that in plpgsql: EXECUTE 'INSERT INTO '||partition_table_name||' VALUES'||(NEW.*)||''; It would probably work, but some values are NULL, and plpgsql interpreter just puts empty space there. So I get ('1',2,3,,,); Which obviously is confusing INSERT. t