Casting to money

Поиск
Список
Период
Сортировка
От Dave Page
Тема Casting to money
Дата
Msg-id E7F85A1B5FF8D44C8A1AF6885BC9A0E40176D38D@ratbert.vale-housing.co.uk
обсуждение исходный текст
Ответы Re: Casting to money  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
A pgAdmin user has just pointed out that the data editor doesn't work with money columns, apparently because it casts
datawhen inserting/updating it. The docs for money say: 

The money type stores a currency amount with a fixed fractional precision; see Table 8-3. Input is accepted in a
varietyof formats, including integer and floating-point literals, as well as "typical" currency formatting, such as
'$1,000.00'.Output is generally in the latter form but depends on the locale.  

Yet:

-- Executing query:
select 123.45::money

ERROR: cannot cast type numeric to money
SQL state: 42846

-- Executing query:
select $123.45::money

ERROR: syntax error at or near ".45"
SQL state: 42601
Character: 12

-- Executing query:
select '$123.45'::money

ERROR: invalid input syntax for type money: "$123.45"
SQL state: 22P02

-- Executing query:
select '£123.00'::money

ERROR: invalid input syntax for type money: "£123.00"
SQL state: 22P02

-- Executing query:
select '123.45'::money

Total query runtime: 0 ms.
[this one returns an empty value]


So my question is, how do we cast input to the money type? Or am I working too late again and being a plank?

Regards, Dave.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PATCHES] Use non-deprecated APIs for dynloader/darwin.c
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Casting to money