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 ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster