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

From Richard Huxton
Subject Re: Maximum limit on int in plpgsql
Date
Msg-id 41AC654D.8050503@archonet.com
Whole thread Raw
In response to Maximum limit on int in plpgsql  (deepthi@granwill.com)
List pgsql-general
deepthi@granwill.com wrote:
> I have tried using the int8 also, even then i am having the problem.

Please CC the list.

The following works for me. I suspect your equivalent of "i" is an int4.

CREATE OR REPLACE FUNCTION test_int8(text) RETURNS int8 AS '
DECLARE
   i   int8;
   tot int8;
BEGIN
     i := CAST($1 AS int8);
     tot := (i * 256 * 256 * 256) + (i * 256 * 256) + (i * 256) + i;
     RETURN tot;
END;
' LANGUAGE plpgsql;

SELECT test_int8('255');

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "Nefnifi, Kasem"
Date:
Subject: starting the database server
Next
From: Richard Huxton
Date:
Subject: Re: starting the database server