Re: Postgres Wishlist - Mailing list pgsql-novice

From Donald Kerr
Subject Re: Postgres Wishlist
Date
Msg-id 2AD99D319C894638AF192798318FB445@DELLM4500
Whole thread Raw
In response to Re: Postgres Wishlist  (Michael Glaesemann <grzm@seespotcode.net>)
Responses Re: Postgres Wishlist
List pgsql-novice
Michael,

First class :) Problem solved!!!

=======================
SELECT col, ('x'||substring(col,1,2))::text::bit(8)::int || ' ' ||
('x'||substring(col,3,2))::text::bit(8)::int || ' ' ||
('x'||substring(col,1,2))::text::bit(8)::int AS oscolor FROM
cartographictext WHERE COL <> '000000' LIMIT 10

Returns:
"0099FF";"0 153 0"
"FF00FF";"255 0 255"
Etc.

Thank you very much to everyone who helped me with this problem.

Regards,

Donald




-----Original Message-----
From: Michael Glaesemann [mailto:grzm@seespotcode.net]
Sent: 13 November 2010 08:45
To: Donald Kerr
Cc: 'Tom Lane'; 'Steve Crawford'; pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Postgres Wishlist



On Nov 13, 2010, at 3:32 , Donald Kerr wrote:

> Thank you, Tom.
>
> I have tried what you suggest but it does not seem to work:
> 'x'||substring(col,3,2)::text::bit(8)::int returns - "9" is not a
> valid binary digit.

Try with parens:

postgres=# select ('x' || 99::text)::bit(8)::int;
 int4
------
  153
(1 row)

postgres=# select version();
                                                                 version

----------------------------------------------------------------------------
--------------------------------------------------------------
 PostgreSQL 9.0.1 on x86_64-apple-darwin10.4.0, compiled by GCC
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664), 64-bit (1
row)


Michael Glaesemann
grzm seespotcode net


pgsql-novice by date:

Previous
From: "Donald Kerr"
Date:
Subject: Re: Postgres Wishlist
Next
From: Michael Glaesemann
Date:
Subject: Re: Postgres Wishlist