Re: SELECT d02name::bytea FROM ... && DBI::Pg

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: SELECT d02name::bytea FROM ... && DBI::Pg
Дата
Msg-id 87zhi5vm0z.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на SELECT d02name::bytea FROM ... && DBI::Pg  (Matthias Apitz <guru@unixarea.de>)
Список pgsql-general
>>>>> "Matthias" == Matthias Apitz <guru@unixarea.de> writes:

 Matthias> Hello,

 Matthias> I can SELECT && print a column in hex with:

 Matthias> pos71=# select d02name::bytea from d02ben where d02bnr = '00001048313' ;

If your intention is to see the raw bytes of the stored text value, for
example to check the encoding, then you should not do it that way.
Casting from text to bytea does NOT do what you think.

Instead use  convert_to(d02name,'SQL_ASCII')  (yes, always specify
SQL_ASCII regardless of what encoding you think it should be in, since
the actual meaning of SQL_ASCII is "no conversions"). For readability,
you may then want to wrap that as
encode(convert_to(d02name,'SQL_ASCII'),'escape')  which will keep the
ASCII characters but use \nnn escapes for non-ascii.

-- 
Andrew (irc:RhodiumToad)



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

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: day interval
Следующее
От: Tom Lane
Дата:
Сообщение: Re: day interval