sqlwrite round up number when use in stand alone app
3 ビュー (過去 30 日間)
古いコメントを表示
I have weird behavior with sqlwrite function when compile as standalone application. I use sqlwrite function to write float number to oracle database using odbc connection. Database is already set corresponding column type to be float(126). When I use function in appdesigner and test in desktop is work fine. Data that write to database was float example I write 123.45 --> database show 123.45.
But when I compile as .exe and test I seem it always round up weirdly. 1.234 --> 1, 14.123 --> 10, 241.123 --> 200. Don't know why it have different output between desktop and .exe.
Anyone have experience?
0 件のコメント
回答 (2 件)
Prathamesh
2023 年 8 月 22 日
Hi,
I understand that you are facing issue with “sqlwrite” function.
It depends on the column type, precision and scale defined, because of which the digits are rounded off or truncated. You can try to set precision of 38 and scale of 16 (or depending on the length of data) for the specific column to fit the data so that it will not get rounded off or truncated.
For example, you can try:
>> execute(conn,'CREATE TABLE testnumeric(COL1 numeric(38,16))')
>> sqlwrite(conn,'testnumeric',table(now,'VariableNames',{'COL1'}))
>> T = sqlread(conn,'testnumeric')
It will give the desired output.
You can also store the data into string in the database and then convert back to float or double in the implementation.
Steven Lord
2023 年 8 月 23 日
I'm guessing that you're computing the values that are being rounded from the input arguments to your application. Is that correct? If so are you taking into account the first point in the "Using a MATLAB File You Plan to Deploy" section on this documentation page?
"The input arguments you pass to your executable from a system prompt are received as character vector input. Thus, if you expect the data in a different format (for example, double), you must first convert the character vector input to the required format in your MATLAB code. For example, you can use STR2NUM to convert the character vector input to numerical data." [Emphasis added.]
参考
カテゴリ
Help Center および File Exchange で Enterprise Deployment with MATLAB Production Server についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!