Re: default column value using a function, trigger, or

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: default column value using a function, trigger, or
Дата
Msg-id 1115160171.13303.1536.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на default column value using a function, trigger, or whatever  ("Roderick A. Anderson" <raanders@tsmg.us>)
Список pgsql-general
On Tue, 2005-05-03 at 17:31, Roderick A. Anderson wrote:
> I am trying to come up with a method to have a default value for a
> column based on a function and other columns.  I'm hoping ( well not too
> much ) that what I figure out here will apply to MS SQL Server as I am
> stuck using it unless I can prove there ain't no way it's going to
> happen.  ( Now that the embarrassment of being stuck using SQL Server is
> out of the way. )
>
> I'd like to populate a column with the md5 of ColA || ':' || ColB || ':'
>   || ColC.  A search of the archives ( with the terms I was using )
> didn't turn up anything useful.
>
> Would this be a function or a trigger?

This will be an after trigger function (everything's a function!  woot!
hehe.  seriously though, all triggers are functions, but not all
functions are triggers, in postgresql land).

Basically, you'll need an after trigger that updates the md5 field with
that cola/b/c bit you've got up there.  Not much to it really.

One of the examples on this page ought to help:

http://www.postgresql.org/docs/8.0/static/plpgsql-trigger.html

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

Предыдущее
От: "Roderick A. Anderson"
Дата:
Сообщение: default column value using a function, trigger, or whatever
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Very interesting article about the future of databases