Suggested (or existing) way to parse currency into numeric?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Suggested (or existing) way to parse currency into numeric?
Дата
Msg-id CAKFQuwbDr3VfgpQKBKM7PNPUNuBLKf_JhFWJAAkhT1rgeeun-g@mail.gmail.com
обсуждение исходный текст
Ответы Re: Suggested (or existing) way to parse currency into numeric?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Version 9.3
CREATE TABLE t ( field numeric NULL );
SELECT * FROM json_populate_record(null::t, '{ "field": "$18,665" }'::json);
Error: invalid input syntax for type numeric: "$18,665"

I can accept the type of field being something like "numeric_cleaned" which has a custom input function that would strip away the symbols and commas (not too concerned about locale at the moment...) and am pondering writing my own custom type with supporting SQL function to accomplish that but I'm hoping the community can point me to something already existing.

I really want to avoid going through a staging table.  I'm more inclined to brute force the source JSON using "jq" (or sed) before I would go that route.

Thoughts, suggestions, comments?

Thank You!

David J.

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: cached row type not invalidated after DDL change
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Suggested (or existing) way to parse currency into numeric?