| От | Martijn van Oosterhout |
|---|---|
| Тема | Re: problem with bit(n) type |
| Дата | |
| Msg-id | 20051012134339.GD20074@svana.org обсуждение |
| Ответ на | problem with bit(n) type (Sergey Karin <sergey.karin@gmail.com>) |
| Список | pgsql-general |
On Wed, Oct 12, 2005 at 12:24:41PM +0400, Sergey Karin wrote: > But if I do something like this: > kosten=# select t::text from foo; > ERROR: cannot cast type bit to text > > I get an error. Okay the system cannot cast bit to text... > But this is the big problem for me... Is there a way to cast bit(n) to > text or varchar? You found the conversion functions, and you can use them to work around this like follows: test=# select textin(bit_out(b'1010')); textin -------- 1010 (1 row) So perhaps: test=# create function bit_to_text (bit) returns text as 'select textin(bit_out($1))' language sql strict immutable; CREATE FUNCTION test=# select substr( bit_to_text( b'10110001' ), 3, 3 ); substr -------- 110 (1 row) Hope this helps, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера