ERROR: value out of range: underflow

Поиск
Список
Период
Сортировка
От Anton Maksimenkov
Тема ERROR: value out of range: underflow
Дата
Msg-id 8cac8dd1002260402o6bf21b8aqa4bca4cd26f235d9@mail.gmail.com
обсуждение исходный текст
Ответы Re: ERROR: value out of range: underflow  (Thom Brown <thombrown@gmail.com>)
Re: ERROR: value out of range: underflow  (Anton Maksimenkov <anton200@gmail.com>)
Список pgsql-general
Hi.

I have a simple function.
CREATE OR REPLACE FUNCTION myf_convert_phone18digits(
 in_phone VARCHAR
) RETURNS BIGINT
-- IMMUTABLE
AS $$
DECLARE
 t_extent_len BIGINT;
 t_phone_18 BIGINT;
 t_multiplier BIGINT;
BEGIN

 IF in_phone IS NULL OR in_phone = '' THEN
    RAISE EXCEPTION 'in_phone[%] IS NULL OR =''''!', in_phone;
 END IF;

 t_extent_len := 18 - length(in_phone);
 t_multiplier := 10::BIGINT ^ t_extent_len::BIGINT; --<<< ERROR HERE
 t_phone_18 := (in_phone)::BIGINT;
 t_phone_18 := t_phone_18 * t_multiplier;

 RETURN t_phone_18;

END;
$$ LANGUAGE plpgsql;


When I try it in pgAdmin, first time it show me error:
--
ERROR:  value out of range: underflow
CONTEXT:  PL/pgSQL function "myf_convert_phone18digits" line 12 at assignment
--
SECOND (and consequences) time it works and just show result 771506000000000000

I get same problem when I try to call query from web (php).
I can't do "second time" here, so web always fail with "ERROR:  value
out of range: underflow"

What's the problem? What can I do with it?
--
antonvm

В списке pgsql-general по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version
Следующее
От: Thom Brown
Дата:
Сообщение: Re: ERROR: value out of range: underflow