Re: triggers and execute...

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: triggers and execute...
Date: 2009-04-27 21:37:22
Message-ID: dcc563d10904271437j18517354j56e72c8021fb6e8f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma
<richard(dot)broersma(at)gmail(dot)com> wrote:
> On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> 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.*)';
>> ...
>>
>> When I create it and try to use it I get this error:
>> ERROR:  NEW used in query that is not in a rule
>> CONTEXT:  SQL statement "insert into page_access_20090427 values (new.*)"
>
> At this point I don't think that there is a way for this function to
> know the correct table type of new.* since page_access_... is still
> only a concatenated string.  There there a way to cast new.* to the
> correct table type as part of this insert statement?

I tried casting the new.*::page_access and that didn't work. For now
I'll carry on with the complete listing of everything.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-04-28 01:44:49 Re: how do you get there from here?
Previous Message Richard Broersma 2009-04-27 21:24:40 Re: triggers and execute...