Re: Reemplazar texto en campo BYTEA

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Leonardo Castillo <leonardo(dot)castillo(at)alejandria(dot)biz>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Reemplazar texto en campo BYTEA
Date: 2009-07-10 00:55:55
Message-ID: 20090710005555.GT6414@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Leonardo Castillo escribió:
> Buenas noches Sr. Alvaro.

Primero que nada permíteme aclarar que nadie me llama "Sr" ... con
Álvaro basta.

> Intenté realizar lo que comenta y me devuelve el mismo error de que no se
> puede hacer casting de bytea a text.
>
> ERROR: cannot cast type bytea to text
> SQL state: 42846
> Character: 31
>
> En la línea: update leo set a = replace(a::text, 'una', 'otra')::bytea;
>
> Estoy usando PG 8.2 y haciendo las operaciones sobre PgAdmin III bajo
> Windows XP.

Bueno, debiste haber partido por ahí ;-) Para convertir bytea en text y vice
versa en 8.2 puedes hacerlo usando las funciones in y out de los
respectivos tipos:

alvherre=# update leo set a = byteain(textout(replace(textin(byteaout(a)), 'una', 'otra')));
UPDATE 1

--
Alvaro Herrera Developer, http://www.PostgreSQL.org/
Syntax error: function hell() needs an argument.
Please choose what hell you want to involve.

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Sergio Gabriel Rodriguez 2009-07-10 01:15:54 Re: [pgsql-es-ayuda] Almacenar acentos y ñ
Previous Message Jaime Giraldo 2009-07-10 00:31:29 Re: Almacenar acentos y ñ