Re: Enc: Help to replace caracter

From: Raj Mathur <raju(at)linux-delhi(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Enc: Help to replace caracter
Date: 2008-11-15 04:06:34
Message-ID: 200811150936.34594.raju@linux-delhi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Friday 14 Nov 2008, paulo matadr wrote:
> I Need to replace string (" ) in the situation below :
>
> select clie_nmcliente from cadastro.cliente where clie_nmcliente
> like '%"%';
>
> result:
> JOANA D"ARCALMEIDA"
> EMLURB "P M R."
> CECILIA D"CAGNO"
> HELENA FERREIRA D"FREITAS"
> JOSE M. "BARRACA DO BOLA"
> FORTE" DUNAS BAR"
> JOANA D"ARC R. DE SOUZA
> ASSEMBLEIA DE DEUS"
> USINA SALGADO"SUPRIMENTO
> JOSE MOURA 'BIGODE"
> BEATRIZ MEDEIROS D"EMERY
>
> Any help me to create pgPL/sql or funcion to replace ( " ) to null
> value, I have many table with this. Thanks for help

For a single field, you can use something like this to achieve your
objective (this will delete all " characters in the field):

update cadastro.cliente
set clie_nmcliente = regexp_replace(clie_nmcliente, '"', '', 'g')
where clie_nmcliente like '%"%'; -- delete all ": not tested!

You could replace the '' with some other string to replace all " with
that string.

It may be quicker to edit an ASCII dump of the database and reload it if
you want to do the same replacement in multiple fields in multiple
tables.

Regards,

-- Raju
--
Raj Mathur raju(at)kandalaya(dot)org http://kandalaya.org/
GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/ || It is the mind that moves

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dean Rasheed 2008-11-15 08:05:04 Re: Delete cascade trigger runs security definer
Previous Message Tom Lane 2008-11-14 18:19:36 Re: Delete cascade trigger runs security definer

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2008-11-15 12:59:50 Re: Query to match location transitions
Previous Message sub3 2008-11-14 19:12:33 Query to match location transitions