pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bit string manipulation in Postgresql
2+ messages / 2 participants
[nested] [flat]

* Bit string manipulation in Postgresql
@ 2002-10-30 01:01 Ericson Smith <ericson@did-it.com>
  2002-10-30 22:00 ` Re: Bit string manipulation in Postgresql Josh Goldberg <josh@4dmatrix.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Ericson Smith @ 2002-10-30 01:01 UTC (permalink / raw)
  To: pgsql-admin

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 plpgsql 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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Bit string manipulation in Postgresql
  2002-10-30 01:01 Bit string manipulation in Postgresql Ericson Smith <ericson@did-it.com>
@ 2002-10-30 22:00 ` Josh Goldberg <josh@4dmatrix.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Goldberg @ 2002-10-30 22:00 UTC (permalink / raw)
  To: Ericson Smith <ericson@did-it.com>; pgsql-admin

http://www.postgresql.org/idocs/index.php?functions-math.html

is this what you're after?

SELECT 1 WHERE B'1010' & B'0110' > B'0001';
returns 1
SELECT 1 WHERE B'1010' & B'0100' > B'0001';
returns null

----- Original Message ----- 
From: "Ericson Smith" <ericson@did-it.com>
To: <pgsql-admin@postgresql.org>
Sent: Tuesday, October 29, 2002 5:01 PM
Subject: [ADMIN] Bit string manipulation in Postgresql


> 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 plpgsql 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
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-10-30 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-10-30 01:01 Bit string manipulation in Postgresql Ericson Smith <ericson@did-it.com>
2002-10-30 22:00 ` Josh Goldberg <josh@4dmatrix.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox