Search Postgresql Archives

EXECUTE in trigger functions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Is there a way of using EXECUTE in trigger functions to to do something like:

CREATE OR REPLACE FUNCTION insert_trigger()
  RETURNS trigger AS
$BODY$
BEGIN
	EXECUTE('INSERT INTO public_partitions.table_'
	|| date_part('year',NEW.eventdate)::VarChar
	|| lpad(date_part('month',NEW.eventdate)::Varchar,2,'0')
	|| lpad(date_part('day',NEW.eventdate)::Varchar,2,'0')
	|| ' VALUES (NEW.*)');
	RETURN NULL;
END;
$BODY$
  LANGUAGE 'plpgsql'

This would obviously be very useful for partitioning - however if I try this I get:

SQL state: 42601
Context: SQL statement "INSERT INTO public_partitions.summary_20080101 VALUES (NEW.*)"
PL/pgSQL function "insert_trigger" line 2 at EXECUTE statement

Thanks,

David.




--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux