pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Дмитрий Иванов <firstdismay@gmail.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: insert column monetary type ver 2
Date: Sat, 20 Nov 2021 08:13:13 -0800
Message-ID: <0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com> (raw )
In-Reply-To: <CAPL5KHpHSCXzB+yX4dDqKBRTtkx+M0rY7_Fc8NJnvVDw9E-iww@mail.gmail.com >
References: <CAPL5KHpHSCXzB+yX4dDqKBRTtkx+M0rY7_Fc8NJnvVDw9E-iww@mail.gmail.com >
On 11/20/21 04:45, Дмитрий Иванов wrote:
> Good afternoon.
> Sorry about the first example.
> I can't figure out the problem. Digit group group separator causes an
> insertion error, what should I do?
> lc_monetary = 'ru_RU.UTF-8'
> Digit group group separator is a space.
> Financial type format: 7,649.00 ₽
> DELETE FROM ONLY bpd.class_prop_user_small_val
> WHERE id_class_prop = 74502;
> Initial version of the data:
> INSERT INTO bpd. class_prop_user_small_val (id_class_prop,
> timestamp_class, val_int, val_boolean, val_varchar, val_real,
> val_numeric, val_date, val_time, val_interval, val_timestamp, val_money,
> val_double, max_val, round, id_class, id_data_type, inheritance,
> val_bigint, min_val, max_on, min_on, round_on) VALUES (74502,
> '2021-09-08 10: 05:12. 618', NULL, NULL, NULL, NULL, NULL, NULL, NULL,
> NULL, NULL, '7 649.00 ₽', NULL, -1, 2, 6161, 6, false, 0, -1, false,
> false, true);
> ----------
> ERROR: invalid input syntax for type money: "7 649,00 ₽" LINE 6: ...,
> NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '7 649,00 ...
> Corrected
> INSERT INTO bpd. class_prop_user_small_val (id_class_prop,
> timestamp_class, val_int, val_boolean, val_varchar, val_real,
> val_numeric, val_date, val_time, val_interval, val_timestamp, val_money,
> val_double, max_val, round, id_class, id_data_type, inheritance,
> val_bigint, min_val, max_on, min_on, round_on) VALUES (74502,
> '2021-09-08 10: 05:12. 618', NULL, NULL, NULL, NULL, NULL, NULL, NULL,
> NULL, NULL, '7649.00 ₽', NULL, -1, 2, 6161, 6, false, 0, -1, false,
> false, true);
> -----------
> INSERT 0 1
>
> Why does a financial type conversion with a legal regional digit group
> separator cause an error?
Because this(cash.c):
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/cash.c;h=d093ce80...
has this?:
/* cash_in()
91 * Convert a string to a cash data type.
92 * Format is [$]###[,]###[.##]
93 * Examples: 123.45 $123.45 $123,456.78
94 *
95 */
The 1000s(group) separator is determined by LC_NUMERIC and I don't
believe that is used by the money type.
--
Adrian Klaver
adrian.klaver@aklaver.com
view thread (21+ messages) latest in thread
Message-ID: <0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com>
Permalink: ../0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com/
Also on: postgresql.org/message-id/0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, firstdismay@gmail.com
Subject: Re: insert column monetary type ver 2
In-Reply-To: <0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com>
References: <CAPL5KHpHSCXzB+yX4dDqKBRTtkx+M0rY7_Fc8NJnvVDw9E-iww@mail.gmail.com> <0d15bb84-565a-0246-2b8f-a0e637239339@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox