Maximum limit on int in plpgsql - Mailing list pgsql-general

From deepthi@granwill.com
Subject Maximum limit on int in plpgsql
Date
Msg-id 1101810555.41ac4b7b33466@granwill.com
Whole thread Raw
Responses Re: Maximum limit on int in plpgsql
Re: Maximum limit on int in plpgsql
List pgsql-general
Hello,

I am passing the ip address as a varchar. Eg: 133.9.4.11

Later on i am splitting the ip address with the delimiter as '.'


ip1t:= split_part($1,'.',1); // returns a text value
ip2t:= split_part($1,'.',2); // returns a text value
ip3t:= split_part($1,'.',3);
ip4t:= split_part($1,'.',4);

Then i am type casting it into an integer

select into ip1 cast(ip1t as integer);
select into ip2 cast(ip2t as integer);
select into ip3 cast(ip3t as integer);
select into ip4 cast(ip4t as integer);

The i am taking the sum using this formula

out_sum=ip1*256*256*256+ip2*256*256+ip3*256+ip4;

When i run the procedure i am getting following error
pg_atoi : Numerical result out of range

I tried all possible datatypes but still i am getting the same error.

Is it the problem of typecasting or the limits on datatype?

Thank you in advance,
deepthi

pgsql-general by date:

Previous
From: "Stefano Bonnin"
Date:
Subject: Temporal query question
Next
From: "Joolz"
Date:
Subject: Re: change natural column order