default column value using a function, trigger, or whatever

From: "Roderick A(dot) Anderson" <raanders(at)tsmg(dot)us>
To: Pg General <pgsql-general(at)postgresql(dot)org>
Subject: default column value using a function, trigger, or whatever
Date: 2005-05-03 22:31:26
Message-ID: 4277FBBE.10103@tsmg.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Actually I can probably find examples in the two PostgreSQL books (
Bruce's and the one from Command Prompt ) I have when I get home tonight
but I couldn't in the docs. There used to be a PostgreSQL Cookbook but
it can't find it -- even doing the Google thing.

Thought, ideas, pointers are welcome.
Rod
--

---
[This E-mail scanned for viruses by Declude Virus]

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2005-05-03 22:42:51 Re: default column value using a function, trigger, or
Previous Message Michael Fuhr 2005-05-03 22:29:43 Re: plpythonu and dollar quoting