Bit-Strings - Is there a more succinct way to do this?

Поиск
Список
Период
Сортировка
От David Johnston
Тема Bit-Strings - Is there a more succinct way to do this?
Дата
Msg-id 005701cc5949$7eeda550$7cc8eff0$@yahoo.com
обсуждение исходный текст
Список pgsql-general

Making use of my first Bit-String and need see which records in a table have at least one position match with a user-supplied comparison string.  The following query is what I am using to do the comparison.

 

SELECT *

FROM (VALUES (B'010',B'01000')) src (vs_bitmap_stock, vs_bitmap_sale)

WHERE 

      ((vs_bitmap_stock & '110'::bit(3)  )::integer > 0 AND

      (vs_bitmap_sale   & '11000'::bit(5))::integer > 0)

 

Also, my source data is actually stored in multiple Boolean fields and I am using the following in a trigger to create a comparable BitString.

 

NEW.vs_bitmap_stock =  (NEW.bool1::integer::text || NEW.bool2::integer::text || NEW.bool3::integer::text)::bit(3)

 

While both are functional they seem to be somewhat obtuse due to all of the casting.  The Bit-String sections of the Data Types, Functions & Operators, sections seem pretty sparse.  I know the concept isn’t that difficult so either I am not doing things in the expected way or the implementation doesn’t directly support the use-case I have in mind.

 

Thanks for any pointers.

 

David J.

 

 

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

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: COPY from .csv File and Remove Duplicates [RESOLVED]
Следующее
От: c k
Дата:
Сообщение: Re: postgresql server crash on windows 7 when using plpython