Insert into partion table without logic statement - Mailing list pgsql-general

From Jolles, Peter M (GE Infra, Energy)
Subject Insert into partion table without logic statement
Date
Msg-id 450587DECE7D17438DC4C9EFD12F0A430AB0A348@ALPMLVEM08.e2k.ad.ge.com
Whole thread Raw
List pgsql-general
I have a table that has multiple partitions (1000+) and I want a trigger
or rule to be able to write data automatically to each partition. One of
the values I am inserting is the table partition name, but I'm not sure
how to use it as a variable in a trigger. All trigger examples have a
series of IF statements, and I don't want to have 1000 IF statements
evaluated on every insert, not to mention adding new statements when I
have new partitions created.

Is something like the following possible? In the current form (below) I
get an INSERT INTO ERROR. I'm relatively new to databases, completely
new to Postgres, so I'm not sure if I'm headed in the right direction or
not. I'm running 8.3.5 if it makes a difference.


CREATE OR REPLACE FUNCTION mytable_insert_trigger()
RETURNS trigger AS
$BODY$
BEGIN
    insert into NEW.PartitionNameVariable values (NEW.*);
    return null;
END;
$BODY$
LANGUAGE 'plpgsql'


Thanks,
Peter

pgsql-general by date:

Previous
From: Sam Mason
Date:
Subject: Re: Adding Arabic dictionary for TSearch2.. to_tsvector('arabic'...) doesn't work..
Next
From: Oleg Bartunov
Date:
Subject: Re: Adding Arabic dictionary for TSearch2.. to_tsvector('arabic'...) doesn't work..