Postgres lc_numeric not working as expected

落爺英雄遲暮 提交于 2019-12-25 08:20:35

问题


I'm on a project that involves a database that uses Danish numeric settings (the decimal separator is a comma). I'm trying to figure out how I can store values in the database as decimal/number/anything but text, but have them keep the comma separator. I've updated the lc_numeric setting in the AWS Parameter group to da_DK, which I found online to be the Danish locale setting, but values are still showing with the period instead of the decimal. What changes need to be made/is this possible?

For instance:

CREATE TABLE test ( 
    num NUMERIC 
);                             // I've also tried Decimal instead of numeric

INSERT INTO test ('1,3')       // error 
INSERT INTO test ('1.3')       // returns 1.3 when selected.
SHOW lc_numeric                // returns da_DK as expected.
SELECT * FROM test;            // 1.3

What am I doing wrong?

Note: this is a postgres instance via AWS RDS, any changes need to be made via the Parameter Group menu and not via the command line.


回答1:


lc_numeric does not influence the string input and output format of numeric types, so it also does not influence the result of type casts.

It only influences the conversion functions to_char and to_number. With regard to the decimal separator, lc_numeric determines the meaning of the D format specifier.



来源:https://stackoverflow.com/questions/41753640/postgres-lc-numeric-not-working-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!