Re: update part of a column - Mailing list pgsql-general

From K Parker
Subject Re: update part of a column
Date
Msg-id IMCLNHLMONMDBAAA@shared1-mail.whowhere.com
Whole thread Raw
List pgsql-general
> I would like to know if I can update part of a column. ie
>
> update myfile set > substr(direct_key,1,10)='1234567890' ....
>
>This does not work. Is this possible?

Not in the way you are attempting to do it.

>Or am I looking at this the wrong way?

Sure: just reassemble the _entire_ column keeping the parts from the original column value that you want to keep, and
insertingthe new parts you want to insert, e.g. 

 update myfile set direct_key =
   '1234567890' || substr(direct_key,11,10)
   where substr(direct_key,1,10) = '0123456789';


Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com

pgsql-general by date:

Previous
From: jprem
Date:
Subject: nested transactions
Next
From: Tom Lane
Date:
Subject: Re: function language type?