Re: What's the logical counterpart of the to_hex function?

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: What's the logical counterpart of the to_hex function?
Дата
Msg-id CFDE27CE-9542-40AE-89E0-0C1B1673429E@blighty.com
обсуждение исходный текст
Ответ на What's the logical counterpart of the to_hex function?  ("Michael Nolan" <htfoot@gmail.com>)
Ответы Re: What's the logical counterpart of the to_hex function?  ("Michael Nolan" <htfoot@gmail.com>)
Список pgsql-general
On Jul 16, 2007, at 11:36 AM, Michael Nolan wrote:

> I have data (from an external source) which is in text format as a
> hex number (it's actually an IP address, but that's probably not
> relevant.)

It likely is relevant, as it means it's a 32 bit unsigned integer,
which isn't something postgresql supports. Depending on what you need
you might want to look at using 32 bit signed, with a 2^31 offset, 64
bit signed, inet or ip4 (which is on pgfoundry, not built-in).

>
> to_hex gets from integer to hex, I can cast a hex constant to
> integer (ie x'12a7'31'::int, but how do I get a database column
> from string/hex to integer?
>

Last time I checked the suggested way to do this was with a plpgsql
function that dynamically creates the cast and does it with exec.
Google for postgresql and hex and you can likely find sample code.

Cheers,
   Steve



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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: pg_dump vs schemas
Следующее
От: Perry Smith
Дата:
Сообщение: deferred check constraints