Skip site navigation (1) Skip section navigation (2)

Re: Trigger Procedure Error: NEW used in query that is not in a rule

From: "Raphael Bauduin" <rblists(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
Cc: "Javier Fonseca V(dot)" <fonsecajavier(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Trigger Procedure Error: NEW used in query that is not in a rule
Date: 2008-09-17 15:08:39
Message-ID: f5227160809170808g410b1203u3d18983feb0d269f@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
HI,

On Sat, Aug 11, 2007 at 9:07 PM, hubert depesz lubaczewski
<depesz(at)depesz(dot)com> wrote:
> On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote:
>> I think that it's working alright except for the next line:
>
> doing this in plpgsql is very complicated (or even impossible assuming
> that any table can have the same trigger). i would rather suggest using
> pl/perl - writing something like this in pl/perl is very simple.
>

I am in the same situation where I would like to execute a query similar to
  EXECUTE 'INSERT INTO ' || quote_ident(SOMEDYNAMICNTABLENAME) || '
SELECT new.*';

I've looked at the plperl documentation, and experimented a bit, but
I'm not even sure how to start this in pl/perl. I hoped to extract
columns from $_TD->{new} but it doesn't seem to work.
Would you have a little example on how you would do it?

Thanks in advance!

Raph






> depesz
>
> --
> quicksil1er: "postgres is excellent, but like any DB it requires a
> highly paid DBA.  here's my CV!" :)
> http://www.depesz.com/ - blog dla ciebie (i moje CV)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

In response to

Responses

pgsql-sql by date

Next:From: Richard BroersmaDate: 2008-09-17 16:20:44
Subject: Re: surrogate vs natural primary keys
Previous:From: Scott MarloweDate: 2008-09-17 14:45:30
Subject: Re: surrogate vs natural primary keys

pgsql-general by date

Next:From: Rodrigo E. De León PlicetDate: 2008-09-17 15:36:00
Subject: Re: FAQ: how to read EXPLAYN ANALYZE and act upon
Previous:From: Ivan Sergio BorgonovoDate: 2008-09-17 14:43:47
Subject: FAQ: how to read EXPLAYN ANALYZE and act upon

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group