Re: Postgres Wishlist

Поиск
Список
Период
Сортировка
От Donald Kerr
Тема Re: Postgres Wishlist
Дата
Msg-id 1B22817AD85B48768451AF84162DA397@DELLM4500
обсуждение исходный текст
Ответ на Re: Postgres Wishlist  (Steve Crawford <scrawford@pinpointresearch.com>)
Ответы Re: Postgres Wishlist  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Steve,

I have already posted asking for help (see below) but hit a brick wall. I
would like to see a modification to allow the conversion from Hex to Dec.

-------------------------------
I am trying to convert from hex to decimal and can do that successfully
using the following code:

SELECT x'FF'::integer;

which outputs 255 and is exactly what I want.

I want to substitute the string in the code 'FF' for a column in the
database like so:

SELECT x'db_column'::integer FROM db_table;

but no matter the combinations I try, I cannot get it to work.

Thew data colum contains html color codes like "0099FF" and I want to
convert these to, in this case, "0 153 255".

The following code behaves well:

SELECT  x'00'::integer || ' ' || x'99'::integer || ' ' ||  x'FF'::integer;

resulting in "0 153 255". All correct

I was hopeful that something similar to the following would work but I just
cannot get it to work despite trying various combinations.

SELECT x'substring(col,1,2)'::integer || ' ' ||
x'substring(col,3,2)'::integer || ' ' || x'substring(col,5,2)'::integer
-------------------------------

Many thanks.

Regards,

Donald



-----Original Message-----
From: Steve Crawford [mailto:scrawford@pinpointresearch.com]
Sent: 12 November 2010 21:01
To: Donald Kerr
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Postgres Wishlist


On 11/12/2010 12:00 PM, Donald Kerr wrote:
> Probably not the correct place to post this message but is there a
> means whereby I can post a suggestion to a PostgreSQL wishlist?
>

In my experience, the best first-step is to ask for help. Explain what
you are trying to solve or the problem you are encountering. In many if
not most cases there is either a solution or explanation. If not, you
will at least have better info about how (and whether or not it would be
productive) to frame your request.

Cheers,
Steve

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1153 / Virus Database: 424/3253 - Release Date: 11/12/10


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Следующее
От: Leon Starr
Дата:
Сообщение: How to properly SET NULL on a delete with two attributes referenced?