开发者

Insert non-English decimal points in mysql

How can you make mysql understand non-English decimal points in integer/float fields?

setLocale(LC_A开发者_如何学编程LL, 'da_DK.ISO-8859-1');

eg:

0,25 will be inserted as 0
0.25 will be inserted as 0.25


One of the reasons you can't do that is that the comma , is used for separating field-values in INSERT statements.

INSERT INTO a(b,c) VALUES (3,4,5) would be ambiguous.

Should it result into b=3.4 , c=5 or b=3 , c=4.5 ?


Numbers aren't affected by locale settings (same in SQL Server too).

So you'd have to send as "0.25"


The easiest way I would think would be to use a wrapper for your mysql object that will set the locale to en_US.utf8 before your query and after the query puts it back to da_DK.ISO-8859-1.

It looks like this does the opposite of what you're looking for.


You might want to try something like REPLACE('3,1415926', ',' , '.' )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜