The
0x prefix means that it is a
hexadecimal number, you can store it as an integer.
To get the hexadecimal notation back you can use the PostgreSQL function
to_hex()
.
More info about hexadecimal here:
Hexadecimal - Wikipedia[
^]
In C# you can convert hex to integer as follows:
Convert.ToInt32("BA", 16)
In PostgreSQL you can use:
select ('x'||lpad(the_hex_value,16,'0'))::bit(64)::bigint;
Or this function:
CREATE OR REPLACE FUNCTION hex_to_int(hexval varchar) RETURNS integer AS $$
DECLARE
result int;
BEGIN
EXECUTE 'SELECT x''' || hexval || '''::int' INTO result;
RETURN result;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;
see:
sql - Convert hex string to bigint in postgres - Stack Overflow[
^]
postgresql - Convert hex in text representation to decimal number - Stack Overflow[
^]