Forum Discussion
pavel-wbr
3 years agoNew Contributor II
culture settings in text to decimal casting
I would like ask about culture settings and how it influence casting from text value to decimal number.
We have an automated import from external system using delimited files and pre-stage table in...
JackLacava
OneStream Employee
3 years agoSo, if you're executing that SQL in a Connector, you must be opening a database connection somewhere; I assume you are using the standard Onestream facilities for this, rather than custom stuff. In order to connect with that, you have to specify the connection details, which is done with a string of key=value parameters:
- If you are using CreateCustomExternalDbConnInfo, you specify the connection string as a parameter in that call
- If you are using CreateExternalDbConnInfo or CreateDbConnInfo, the connection string has been specified in the OneStream Application Server Settings using the related utility (described in the Installation guide, search for "Defining Database Connections Manually"). To build the initial string, you can leverage the OneStream Database Configuration utility, which has a wizard to connect to databases and allows you to generate a connection string.
The actual parameters you can pass in that string should be https://learn.microsoft.com/en-us/sql/relational-databases/native-client/applications/using-connection-string-keywords-with-sql-server-native-client?view=sql-server-ver16 , which include a Language option and a Regional switch that I think could influence things.
To be honest, I wouldn't mess with all this. If the explicit conversion in sql works, just keep using that; if you are pulling those numbers from a DataTable object to convert to strings, just call .ToString on them with culture-specific parameters to get what you want, e.g. myDecimal.ToString("N3", CultureInfo.InvariantCulture) will always give you "1,234.123" (because InvariantCulture is based on US-English - if you want something else you can use CultureInfo.getCultureInfo("some culture") instead of CultureInfo.InvariantCulture). See https://learn.microsoft.com/en-us/dotnet/api/system.decimal.tostring?view=net-7.0#system-decimal-tostring(system-string-system-iformatprovider) for more details.
This is all generic advice, to be more precise we would have to see the actual connector code that executes that statement, and maybe what happens when you change things.
pavel-wbr
3 years agoNew Contributor II
Hi Jack, do you have any news to my problem?
Thanks,
Pavel
Related Content
- 10 months ago
- 3 years ago
- 3 years ago