On Sat, Dec 12, 2009 at 7:05 PM, zxo102 ouyang <zxo102@xxxxxxxxx> wrote: > Hi evreyone, > I have a table with two fields > > field1 field2 > 1 1channel > 2 2channel > 3 3channel > > Now I want to add the third one with the value > replace(field2,'channel','AAAA') like > > field1 field2 field3 > 1 1channel replace(field2,'channel','AAAA') > 2 2channel replace(field2,'channel','AAAA') > 3 3channel replace(field2,'channel','AAAA') > > The field3 must be done automatically after a user input data into field1 > and field2. > > Any ideas? Thanks a lot. So, where are you headed. Should the third field ALWAYS be field2 with channel replcaed by AAAA? Or could it change after you've set it at first to that? If it will always be the same as field2 with the replacement, then creating a simple updatable view with the third row always computed is a reasonable choice. If you just want it set on insert or update of field2, but then want it to be modifiable, then a trigger might be a good answer. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general