"Kiarash Bodouhi" <kbodouhi(at)yahoo(dot)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