setting default value by "trigger"

Поиск
Список
Период
Сортировка
От Barbara Lindsey
Тема setting default value by "trigger"
Дата
Msg-id 4027B42E.7020100@cog.ufl.edu
обсуждение исходный текст
Ответы Re: setting default value by "trigger"  ("Ed L." <pgsql@bluepolka.net>)
Список pgsql-general
I have a case where I am collecting a "Start Date" and an "End Date".
I would like to default the "End Date" to the "Start Date" value if only
the "Start Date" is entered.
I tried setting this as default on the table, but it was not permitted.
So, now I am trying to figure out how to do it with a trigger or
trigger/function combination.

I tried doing it with a rule using "INSTEAD" on INSERT, but that gave an
"endless recursion" error, which did make ssense after I looked at it
more closely.

I also tried making a trigger, which called a function that changed the
value of the NEW.enddate to the NEW.startdate value if NEW.enddate is
NULL, but I got an error saying that the NEW. values were not available
yet (doing trigger BEFORE INSERT).

Has anyone else done something like this, and if so, what approach
worked for you?
Thanks.
Barb

--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314     Fax: (352) 392-8162

----
CONFIDENTIALITY NOTICE: The information contained in this electronic
message is legally privileged and confidential and intended only for the
use of the individual(s) or entity(ies) named above.  If the reader of
this message is not the intended recipient, you are hereby notified that
any dissemination, distribution, or copying of this email or any of it's
components is strictly prohibited.  If you have received this email in
error, please contact the sender.
----


В списке pgsql-general по дате отправления:

Предыдущее
От: "Bas Scheffers"
Дата:
Сообщение: Re: TSearch and rankings
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: I want to use postresql for this app, but...