Re: Cast text to bytea: the Solution

Поиск
Список
Период
Сортировка
От Alvar Freude
Тема Re: Cast text to bytea: the Solution
Дата
Msg-id 1465860000.1070457807@gnarzelwicht.delirium-arts.de
обсуждение исходный текст
Ответ на Re: Cast text to bytea  (Alvar Freude <alvar@a-blast.org>)
Список pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

- -- Alvar Freude <alvar@a-blast.org> wrote:
>
>   odem=> UPDATE forum_gtree SET gid2=(DECODE(gid::text, 'escape'));
>   ERROR:  decode: Bad input string for type bytea

the solution is: backslashes in the text column are interpreted as escapes.
So: they must be marked escaped first. Replacing "\" with "\\" does this:

  UPDATE table SET bytea_col =
    (decode(replace(text_col, '\\', '\\\\'), 'escape'));


This seems to work and looks like there are the correct values in the new
column ...


Ciao
  Alvar

- --
** Alvar C.H. Freude -- http://alvar.a-blast.org/
**   Berufsverbot? http://odem.org/aktuelles/staatsanwalt.de.html
**   ODEM.org-Tour: http://tour.odem.org/
**   Informationsgesellschaft: http://www.wsis-koordinierungskreis.de/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/zePPOndlH63J86wRAmEaAJ9LAWvLFwekca58BTWYYBuPgWrawACeJRjl
POrmVVWkT0+XmF7clqBtKlA=
=wH3M
-----END PGP SIGNATURE-----


В списке pgsql-general по дате отправления:

Предыдущее
От: "Claudio Lapidus"
Дата:
Сообщение: Re: Money data type in PostgreSQL?
Следующее
От: Barbara Lindsey
Дата:
Сообщение: Re: DBD::Pg problem