Re: hex values

From: Heiko Klein <Heiko(dot)Klein(at)met(dot)no>
To: "Oberpriller, Wade D(dot)" <oberpwd(at)nsc-msg01(dot)network(dot)com>
Cc: "PostgreSQL General Help (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: hex values
Date: 2002-04-04 13:32:48
Message-ID: 15532.22016.838367.453471@polar.oslo.dnmi.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

as far as I've found out, it doesn't.
Retrieving int data as hex I solved by this plperl function:

CREATE FUNCTION int2hex(integer) RETURNS char(10)
AS '$tmp = sprintf "%X", $_[0];
return ("0x" . "0"x(4-length($tmp)) . $tmp);'
LANGUAGE 'plperl';

This will give you allways 4 ciphers behind 0x. I didn't need it for
reading data, but at least, it should work about the same, i.e. if you have
several kinds of numbers, some dec, some hex, some oct, I would do
something like:

CREATE FUNCITON mynumber2int(char(10)) RETURNS integer
AS 'return int($_[0]);'
LANGUAGE 'plperl';

which simply uses perls internal conversion-mechanism.

I would also like postgres to include this behavior by default, at least
for the reading. But I haven't found out how.

Heiko

Oberpriller, Wade D. writes:
> Does Postgres support hex values?
>
> Can I do something like:
>
> VAL := 0xFFFF;
>
> And is it possible to output the value in a hex-string? So VAL would display
> as 0xFFFF instead of 65535?
>
> Wade Oberpriller http://www.storagetek.com
> Software Development Phone: (763) 424-1538
> StorageTek: MRDC (800) 328-9108 ext. 1538
> wade_oberpriller(at)storagetek(dot)com Fax: (763) 391-1095
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

  • hex values at 2002-04-03 21:11:43 from Oberpriller, Wade D.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Denis Gasparin 2002-04-04 14:32:44 Re: binary data storage
Previous Message Martín Marqués 2002-04-04 12:07:45 Re: binary data storage