hex values 
Author Message
 hex values

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.***.com/
Software Development             Phone: (763) 424-1538
StorageTek: MRDC                        (800) 328-9108 ext. 1538

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.***.com/



Mon, 20 Sep 2004 05:18:06 GMT
 hex values

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

Quote:
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

 >
 > ---------------------------(end of broadcast)---------------------------
 > TIP 6: Have you searched our list archives?
 >
 > http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Mon, 20 Sep 2004 21:34:39 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Displaying hex values in Access97

2. Updating Hex values bit wise with one SQL statement

3. Outputting Hex values from Oracle

4. Converting a string hex value to an integer.

5. Converting a Hex value to Binary in a stored Procedure

6. Converting Hex values

7. FPW 2.6 - Converting to a hex value

8. D3 VB brWrite Hex values

9. Greatest HEX Value in a Database

10. Could not convert UTF-8 to ISO8859-1 but no hex-value

11. Display Hex values of a character string


 
Powered by phpBB® Forum Software