Thread: Bit srting manipulation question

Bit srting manipulation question

From
Ericson Smith
Date:
Hi all,

I'm trying to code a problem where a set of options can be expressed in
a data column like "10111011", a bit string.

Each position is atomic and represents a certain setting within the set,
thus: "00100000" would return TRUE if OR'd with "10111011", since the
3'rd position matches in both sets.

While I could manually retrieve N records and iterate through them in
whatever programming language (or possibly a postgresql function), is
there a way I could natively do this in a WHERE clause in my query?

Looking through the idocs, I could not immediately find a way around
this issue. Any pointers to documentation (or perhaps another way to
implement this issue) would be very helpful.

Regards
Ericson Smith
eric@did-it.com






Re: Bit srting manipulation question

From
Bruno Wolff III
Date:
On Tue, Oct 29, 2002 at 20:11:27 -0500,
  Ericson Smith <eric@did-it.com> wrote:
>
> Each position is atomic and represents a certain setting within the set,
> thus: "00100000" would return TRUE if OR'd with "10111011", since the
> 3'rd position matches in both sets.
>
> While I could manually retrieve N records and iterate through them in
> whatever programming language (or possibly a postgresql function), is
> there a way I could natively do this in a WHERE clause in my query?

If you can store them as integers then you can use the binary and and binary
or operators to do this kind of thing.