Re: Rule problem

From: "Kiarash Bodouhi" <kbodouhi(at)yahoo(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rule problem
Date: 2004-10-10 16:03:18
Message-ID: 003401c4aee2$aa9c7a00$0a00a8c0@kibotop2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the reply. I initially wanted to put the function as the default
clause. But the problem is that the function should receive one of the other
fields as the argument. Is there anyway to do that? I guess as you said I
have to use triggers.

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Sunday, October 10, 2004 4:53 PM
To: Kiarash Bodouhi
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Rule problem

"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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2004-10-10 16:05:56 Re: Change query priority
Previous Message Tom Lane 2004-10-10 15:53:15 Re: Rule problem