Re: RULE - special variables?

Lists: pgsql-general
From: Matthew Peter <survivedsushi(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: RULE - special variables?
Date: 2006-11-08 23:15:23
Message-ID: 20061108231523.15354.qmail@web35211.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Do rules get special variables like triggers? Can I set variables in them like
triggers?


____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail.
http://new.mail.yahoo.com


From: Richard Huxton <dev(at)archonet(dot)com>
To: Matthew Peter <survivedsushi(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: RULE - special variables?
Date: 2006-11-09 09:24:29
Message-ID: 4552F3CD.10403@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Matthew Peter wrote:
> Do rules get special variables like triggers? Can I set variables in them like
> triggers?

You get NEW/OLD but they mean something subtly different. Rules act on a
query-tree so they are more like placeholders.

You can't set variables in triggers. You do so in a function. If your
rule calls a function, that could have variables.

Spend some time playing with rules - make sure you understand the
difference between them and triggers.
--
Richard Huxton
Archonet Ltd


From: Matthew Peter <survivedsushi(at)yahoo(dot)com>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: RULE - special variables?
Date: 2006-11-10 02:06:00
Message-ID: 20061110020600.36981.qmail@web35208.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


--- Richard Huxton <dev(at)archonet(dot)com> wrote:

> Matthew Peter wrote:
> > Do rules get special variables like triggers? Can I set variables in them like
> > triggers?
>
> You get NEW/OLD but they mean something subtly different. Rules act on a
> query-tree so they are more like placeholders.
>
> You can't set variables in triggers. You do so in a function. If your
> rule calls a function, that could have variables.

You can set variables in triggers in the DECLARE block when plpgsql is used.

Reading the docs they only show single-statement rules so it never said assigning
could be done so here I am. Sometimes it's easier to write a quick rule than a
trigger function and separate firing condition, especially when they function so
similiarily in theory. Thanks.


____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com