Re: two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')? - Mailing list pgsql-general

From Scott Marlowe
Subject Re: two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?
Date
Msg-id dcc563d10912122003p217c20c1q35f9bbc710c6098a@mail.gmail.com
Whole thread Raw
In response to two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?  (zxo102 ouyang <zxo102@gmail.com>)
List pgsql-general
On Sat, Dec 12, 2009 at 7:05 PM, zxo102 ouyang <zxo102@gmail.com> 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.

pgsql-general by date:

Previous
From: zxo102 ouyang
Date:
Subject: two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?
Next
From: "关外流浪"
Date:
Subject: getaddrinfo.c error