Re: Altering field passed as parameter to plpgsql trigger

From: Richard Huxton <dev(at)archonet(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Altering field passed as parameter to plpgsql trigger
Date: 2007-12-12 20:27:34
Message-ID: 47604436.1080509@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Crawford wrote:

> What is the correct syntax for the line:
> new.field_to_alter = some_computed_value;

Can't be done in plpgsql - it's too static a language. On first call,
that assignments basically gets compiled into a planned query and from
then on you're stuck.

You can use pl/tcl or pl/perl etc. since they're more dynamic.

> Also, does plpgsql have a preferred way to identify the table that fired
> the trigger. I see the syntax for C but not for plpgsql.

TG_RELNAME / TG_TABLE_NAME - it's in the plpgsql/triggers section of the
manual.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pilzner 2007-12-12 20:28:37 Re: Better alternative for Primary Key then serial??
Previous Message Joshua D. Drake 2007-12-12 20:25:56 Re: Slow PITR restore