Fwd: triggers and execute...

From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Fwd: triggers and execute...
Date: 2009-05-01 14:03:40
Message-ID: 5BA09A7B-95F6-469E-9887-6DDBA8894C66@hi-media.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, it seems it didn't make it the first time.

Début du message réexpédié :

> De : Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
> Date : 30 avril 2009 12:03:10 HAEC
> À : pgsql-general(at)postgresql(dot)org
> Objet : Rép : [GENERAL] triggers and execute...
>
> On Monday 27 April 2009 22:32:22 Scott Marlowe wrote:
>> OK, I'm hitting a wall here. I've written this trigger for
>> partitioning:
>>
>> create or replace function page_access_insert_trigger ()
>> returns trigger as $$
>> DECLARE
>> part text;
>> q text;
>> BEGIN
>> part = to_char(new."timestamp",'YYYYMMDD');
>> q = 'insert into page_access_'||part||' values (new.*)';
>
> What you want looks like this (thanks RhodiumToad):
>
> 'INSERT INTO page_access_' || part ||
> 'SELECT (' || quote_literal(textin(record_out(NEW))) ||
> '::page_access).*;'
>
> That's supposing you have a parent table named page_access, of
> course. And
> casting this way has drawbacks too (which I can't recall at this
> moment), but
> I've been using this live for maybe more than a year now without any
> problem.
>
>> It works. So, how am I supposed to run it with dynamic table names?
>
> Hack your way around, partitioning is not yet there "for real"...

--
dim

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-05-01 14:25:40 Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully
Previous Message Bill Moran 2009-05-01 13:44:48 Re: Re: Mapping output from a SEQUENCE into something non-repeating/colliding but random-looking?