to_number, to_char inconsistency.

Поиск
Список
Период
Сортировка
От Jeremy Lowery
Тема to_number, to_char inconsistency.
Дата
Msg-id CAPzVRBq32NQRx9+WZboOCRdUS_V__O9TWq76_hUWTLE=5oiJNg@mail.gmail.com
обсуждение исходный текст
Ответы Re: to_number, to_char inconsistency.  (Szymon Guz <mabewlun@gmail.com>)
Re: to_number, to_char inconsistency.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I load and dump text files with currency values in it. The decimal in these
input and output formats in implied. The V format character works great for
outputing numeric data:

# select to_char(123.45, '999V99');
 to_char
---------
  12345
(1 row)


However, when importing data, the V doesn't do the same thing:

# select to_number('12345', '999V99');
ERROR:  numeric field overflow
DETAIL:  A field with precision 3, scale 0 must round to an absolute value
less than 10^3.


So I have to do this:
# select to_number('12345', '99999')/100;

Is there an easier way to insert this into a NUMERIC(5, 2) field?

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

Предыдущее
От: Kenneth Tilton
Дата:
Сообщение: Re: Swapping volumes under tablespaces: supported?
Следующее
От: Szymon Guz
Дата:
Сообщение: Re: to_number, to_char inconsistency.