On Fri, 8 Nov 2002, Peter Nixon wrote:
> On Fri, 8 Nov 2002 12:03:15 +0000 (UTC)
> Squire "Nigel J. Andrews" uttered the following:
>
> Well, they are generated by cisco routers. They are the conference id for
> each voip call and "should" be unique (at least to each router).
> This (41A4DCE3 8CF2D611 85170004 75AE73D4) is the format they come out of
> the router in, and I am just inserting the data directly to a text field.
> You are right, they do seem to be hex numbers. Can postgres accept hex as a
> numberic? if so that would speed things up ALOT...
I'm sure it must be possible but I can't see anything at the moment. So how
about:
create function hex_to_int (text) returns integer as '
return hex($_[0]);
' language 'plpgsql';
create function int_to_hex (integer) returns text as '
return sprintf("%X",$_[0]);
' language 'plpgsql';
Used as:
insert int mytable values (hex_to_int('AB456F56'));
and
select int_to_hex(colname) from mytable;
You'd need to be confident that you weren't going to exceed your native integer
size in perl though.
--
Nigel J. Andrews