Re: numeric to ipv6 inet

From: Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com>
To: Mikhail Puzanov <misha(dot)puzanov(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: numeric to ipv6 inet
Date: 2013-08-23 14:07:19
Message-ID: CADgbbqjwNEVPAHS2Su1Kj=fdj+Jx7vpZ-fKY=U3Nvun7gTQvKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2013/8/23, Mikhail Puzanov <misha(dot)puzanov(at)gmail(dot)com>:
> Hello,
>
> I need to convert the set of ipv6 addresses stored as numerics
> (by historical reasons mostly) to inet type.
>
> Something like
> '0:0:0:0:0:0:0:0'::inet + 55831599345971591062080247067748335616::bigint
> apparently doesn't work as the number added is too big to be converted to
> bigint.
>
> Is there any reasonable way to do it in sql/pgplsql?
>

From manual:
bigint
8 bytes
large-range integer -9223372036854775808 to 9223372036854775807

http://www.postgresql.org/docs/current/interactive/datatype-numeric.html#DATATYPE-INT

So 55831599345971591062080247067748335616 is out-of-range for a bigint.

Osvaldo

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2013-08-23 14:32:47 Re: Column names for INSERT with query
Previous Message sachin kotwal 2013-08-23 10:29:14 Re: filling database