pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Change a character in a text field
6+ messages / 4 participants
[nested] [flat]

* Change a character in a text field
@ 2008-07-01 20:58  Naomi Walker <nwalker@mhs.mphasis.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Naomi Walker @ 2008-07-01 20:58 UTC (permalink / raw)
  To: pgsql-admin

Is there some way with a SQL state to interrogate a text field, and 
replace characters.

For example, we would like all "|"'s to be changed to something else, on 
a regular basis...
We could unload the rows, change them, and load back, but was hoping 
someone had
a slicker way to do it in place..

Thanks,
Naomi

-- 
------------------------------------------------------------------------
Naomi Walker                          Chief Information Officer
Eldorado Computing, Inc               nwalker@eldocomp.com
  ---An EDS Company                   602-604-3100
------------------------------------------------------------------------
The more I want to get something done, the less I call it work.
   - Richard Bach
------------------------------------------------------------------------

-- CONFIDENTIALITY NOTICE --

Information transmitted by this e-mail is proprietary to MphasiS and/or its Customers and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this e-mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at mailmaster@mphasis.com and delete this mail from your records.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Change a character in a text field
@ 2008-07-01 21:22  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Naomi Walker <nwalker@mhs.mphasis.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Kevin Grittner @ 2008-07-01 21:22 UTC (permalink / raw)
  To: Naomi Walker <nwalker@mhs.mphasis.com>; pgsql-admin

>>> Naomi Walker <nwalker@mhs.mphasis.com> wrote: 
> Is there some way with a SQL state to interrogate a text field, and 
> replace characters.
> 
> For example, we would like all "|"'s to be changed to something else,
on 
> a regular basis...
 
It sounds like you might want to look at the regexp_replace function:
 
http://www.postgresql.org/docs/8.3/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP
 
Be sure to use a WHERE clause on your UPDATE with the ~ operator.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Change a character in a text field
@ 2008-07-01 23:00  Karen Stone <kstone@mhs.mphasis.com>
  parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
  0 siblings, 3 replies; 6+ messages in thread

From: Karen Stone @ 2008-07-01 23:00 UTC (permalink / raw)
  To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; Naomi Walker <nwalker@mhs.mphasis.com>; pgsql-admin

Can you please provide a complete example of how to use this in the
update command?  ie... how do we select the table/field that we want to
interrogate and make the change to?

Thanks!

Karen Stone
Technical Services
MphasiS Health Solutions
602.604.3100 x265

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Kevin Grittner
Sent: Tuesday, July 01, 2008 2:23 PM
To: Naomi Walker; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Change a character in a text field

>>> Naomi Walker <nwalker@mhs.mphasis.com> wrote: 
> Is there some way with a SQL state to interrogate a text field, and 
> replace characters.
> 
> For example, we would like all "|"'s to be changed to something else,
on 
> a regular basis...
 
It sounds like you might want to look at the regexp_replace function:
 
http://www.postgresql.org/docs/8.3/interactive/functions-matching.html#F
UNCTIONS-POSIX-REGEXP
 
Be sure to use a WHERE clause on your UPDATE with the ~ operator.
 
-Kevin

-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

-- CONFIDENTIALITY NOTICE --

Information transmitted by this??e-mail is proprietary to MphasiS and/or its Customers and is intended for use only by the individual or entity to which it is addressed, and may contain information that is??privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this e-mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at mailmaster@mphasis.com and delete this mail from your records.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Change a character in a text field
@ 2008-07-02 01:41  Naomi Walker <nwalker@eldocomp.com>
  parent: Karen Stone <kstone@mhs.mphasis.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Naomi Walker @ 2008-07-02 01:41 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>

Karen Stone wrote:
> Can you please provide a complete example of how to use this in the
> update command?  ie... how do we select the table/field that we want to
> interrogate and make the change to?
>
> Thanks!
>
> Karen Stone
> Technical Services
> MphasiS Health Solutions
> 602.604.3100 x265
>
> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org
> [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Kevin Grittner
> Sent: Tuesday, July 01, 2008 2:23 PM
> To: Naomi Walker; pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] Change a character in a text field
>
>   
>>>> Naomi Walker <nwalker@mhs.mphasis.com> wrote: 
>>>>         
>> Is there some way with a SQL state to interrogate a text field, and 
>> replace characters.
>>
>> For example, we would like all "|"'s to be changed to something else,
>>     
> on 
>   
>> a regular basis...
>>     
>  
> It sounds like you might want to look at the regexp_replace function:
>  
> http://www.postgresql.org/docs/8.3/interactive/functions-matching.html#F
> UNCTIONS-POSIX-REGEXP
>  
> Be sure to use a WHERE clause on your UPDATE with the ~ operator.
>  
> -Kevin
>
>   




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Change a character in a text field
@ 2008-07-02 17:35  Naomi Walker <nwalker@mhs.mphasis.com>
  parent: Karen Stone <kstone@mhs.mphasis.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Naomi Walker @ 2008-07-02 17:35 UTC (permalink / raw)
  To: pgsql-admin


> Can you please provide a complete example of how to use this in the
> update command?  ie... how do we select the table/field that we want to
> interrogate and make the change to?
>
> Thanks!
>
> Karen Stone
> Technical Services
> MphasiS Health Solutions
> 602.604.3100 x265
>
> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org
> [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Kevin Grittner
> Sent: Tuesday, July 01, 2008 2:23 PM
> To: Naomi Walker; pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] Change a character in a text field
>
>   
>>>> Naomi Walker <nwalker@mhs.mphasis.com> wrote: 
>>>>         
>> Is there some way with a SQL state to interrogate a text field, and 
>> replace characters.
>>
>> For example, we would like all "|"'s to be changed to something else,
>>     
> on 
>   
>> a regular basis...
>>     
>  
> It sounds like you might want to look at the regexp_replace function:
>  
> http://www.postgresql.org/docs/8.3/interactive/functions-matching.html#F
> UNCTIONS-POSIX-REGEXP
>  
> Be sure to use a WHERE clause on your UPDATE with the ~ operator.
>  
> -Kevin
>
>   


-- 
------------------------------------------------------------------------
Naomi Walker                          Chief Information Officer
Eldorado Computing, Inc               nwalker@eldocomp.com
  ---An EDS Company                   602-604-3100
------------------------------------------------------------------------
The more I want to get something done, the less I call it work.
   - Richard Bach
------------------------------------------------------------------------


-- CONFIDENTIALITY NOTICE --

Information transmitted by this e-mail is proprietary to MphasiS and/or its Customers and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this e-mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at mailmaster@mphasis.com and delete this mail from your records.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Change a character in a text field
@ 2008-07-02 18:07  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Karen Stone <kstone@mhs.mphasis.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2008-07-02 18:07 UTC (permalink / raw)
  To: Karen Stone <kstone@mhs.mphasis.com>; Naomi Walker <nwalker@mhs.mphasis.com>; pgsql-admin

>>> Karen Stone <kstone@mhs.mphasis.com> wrote: 
>>> Is there some way with a SQL state to interrogate a text field, and

>>> replace characters.
>>> 
>>> For example, we would like all "|"'s to be changed to something
else,
>>> on 
>>> a regular basis...
>>  
>> It sounds like you might want to look at the regexp_replace
function:
>>  
>>
http://www.postgresql.org/docs/8.3/interactive/functions-matching.html#F
>> UNCTIONS-POSIX-REGEXP
>>  
>> Be sure to use a WHERE clause on your UPDATE with the ~ operator.
>  
> Can you please provide a complete example of how to use this in the
> update command?  ie... how do we select the table/field that we want
to
> interrogate and make the change to?
 
Assuming standard_conforming_strings is on, this (untested) should do
it:
 
UPDATE sometable
  SET somecolumn = regexp_replace(somecolumn, '\|', 'something else',
'g')
  WHERE somecolumn ~ '\|';
 
If standard_conforming_strings is off, double the backslashes.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2008-07-02 18:07 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-01 20:58 Change a character in a text field Naomi Walker <nwalker@mhs.mphasis.com>
2008-07-01 21:22 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2008-07-01 23:00   ` Karen Stone <kstone@mhs.mphasis.com>
2008-07-02 01:41     ` Naomi Walker <nwalker@eldocomp.com>
2008-07-02 17:35     ` Naomi Walker <nwalker@mhs.mphasis.com>
2008-07-02 18:07     ` Kevin Grittner <Kevin.Grittner@wicourts.gov>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox