Re: Rule problem - Mailing list pgsql-general

From Tom Lane
Subject Re: Rule problem
Date
Msg-id 10802.1097423595@sss.pgh.pa.us
Whole thread Raw
In response to Rule problem  ("Kiarash Bodouhi" <kbodouhi@yahoo.com>)
Responses Re: Rule problem  ("Kiarash Bodouhi" <kbodouhi@yahoo.com>)
List pgsql-general
"Kiarash Bodouhi" <kbodouhi@yahoo.com> writes:
> I tried to use following rule instead of using a default value

You can't ... at least not that way.

> (I want to be
> able to put a function instead of the constant value later on).

There's nothing stopping you from putting a function into the DEFAULT
clause.

A "BEFORE INSERT" trigger is another possible approach.

Novices often think that rules are simpler to use than triggers,
but in my experience the opposite is true.  Triggers have some
notational ugliness but the conceptual model is simple ... for
rules the notation looks easy but wrapping your head around what
will really happen is another story.

            regards, tom lane

pgsql-general by date:

Previous
From: Dawid Kuroczko
Date:
Subject: Re: Change query priority
Next
From: "Kiarash Bodouhi"
Date:
Subject: Re: Rule problem