Re: using NEW in a trigger calling a function in plpgsql...

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Creager, Robert S" <CreagRS(at)LOUISVILLE(dot)STORTEK(dot)COM>
Cc: "'General - PGSQL'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: using NEW in a trigger calling a function in plpgsql...
Date: 2001-03-22 01:56:02
Message-ID: Pine.BSF.4.21.0103211753220.37768-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 21 Mar 2001, Creager, Robert S wrote:

> I'm attempting to create update/insert/delete triggers which end up relying
> on two functions, add_influence and remove_influence (both plpgsql
> functions). I've attempted to call these functions which accepts a known
> table as a parameter, and am PERFORM'ing a call to that function with NEW as
> the parameter. The error I receive is: ERROR: NEW used in non-rule query.
> Can I accomplish this in plpgsql, or do I need to switch over to C/C++? I
> would prefer to not re-select the data info another variable...

Trigger functions take no arguments and return opaque. Inside the plpgsql
trigger you should automatically get NEW as the appropriate row, you
shouldn't need to pass it in (you can use NEW in the body of the
functions).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Limin Liu 2001-03-22 02:03:45 Can I use SPI in postgres.c
Previous Message Jeff 2001-03-22 01:33:49 How to copy table?