Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[GENERAL] two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?

0 views
Skip to first unread message

zxo102 ouyang

unread,
Dec 12, 2009, 9:05:44 PM12/12/09
to
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.
 
ouyang

Scott Marlowe

unread,
Dec 12, 2009, 11:03:29 PM12/12/09
to

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-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

0 new messages