EXECUTE in trigger functions.

From: David Brain <dbrain(at)bandwidth(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: EXECUTE in trigger functions.
Date: 2008-10-27 16:30:08
Message-ID: 41E9D101-2518-4E89-98FF-743394D0AAAB@bandwidth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Cave-Ayland 2008-10-27 16:39:04 PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?
Previous Message Simon Riggs 2008-10-27 16:12:18 Re: [HACKERS] Hot Standby utility and administrator functions