Re: rules and functions as arguments - Mailing list pgsql-general

From Tom Lane
Subject Re: rules and functions as arguments
Date
Msg-id 25878.1030629696@sss.pgh.pa.us
Whole thread Raw
In response to rules and functions as arguments  (Jeff Davis <list-pgsql-general@empires.org>)
List pgsql-general
Jeff Davis <list-pgsql-general@empires.org> writes:
> Is there a way I can make it only do a function call once, and use the value
> after that for all NEW.id's?

No.  A rule is a macro, and so it has all the standard issues about
multiple evaluations of arguments.

> Is a trigger a better option here perhaps?

Yes.  If you want access to the specific values inserted, a trigger is
almost always a better bet.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: date_part???
Next
From: "Ben-Nes Michael"
Date:
Subject: Re: join problem or maybe group :(