lurcher / unixODBC

The unixODBC Project goals are to develop and promote unixODBC to be the definitive standard for ODBC on non MS Windows platforms.
GNU Lesser General Public License v2.1
100 stars 52 forks source link

Invalid precision value #165

Open kothapraveen opened 6 months ago

kothapraveen commented 6 months ago

Hi Team, Currently we are facing below Exception, when we execute the statement query.

Exception: (0, HY104, '[mtodbc]: Binding parameter: [FreeTDS][SQL Server]Invalid precision value')

ODBC Logs: [ODBC][16228][1710915952.043190][SQLBindParameter.c][217] Entry: Statement = 0x120bec0 Param Number = 11 Param Type = 4 C Type = 1 SQL_C_CHAR SQL Type = 2 SQL_NUMERIC Col Def = 255 Scale = 3 Rgb Value = 0x121dda0 Value Max = 258 StrLen Or Ind = 0x120b490 [ODBC][16228][1710915952.043243][SQLBindParameter.c][434] Exit:[SQL_ERROR] [ODBC][16228][1710915952.043374][SQLGetDiagRecW.c][535] Entry: Statement = 0x120bec0 Rec Number = 1 SQLState = 0x7fbecba5e8e0 Native = 0x7fbecba5e8ec Message Text = 0x7fbecba5e4e0 Buffer Length = 511 Text Len Ptr = 0x7ffd6fed425e DIAG [HY104] [FreeTDS][SQL Server]Invalid precision value

[ODBC][16228][1710915952.043486][SQLGetDiagRecW.c][596] Exit:[SQL_SUCCESS] SQLState = [HY104] Native = 0x7fbecba5e8ec -> 0 (32 bits) Message Text = [[FreeTDS][SQL Server]Invalid precision value].

sql logs: odbc.c:1412:_SQLBindParameter(0x1da33d0, 11, 4, 1, 2, 255, 3, 0x1db4450, 258, 0x1da19e0) error.c:414:odbc_errs_add: "Invalid precision value" error_export.h:19:SQLGetDiagRecW(3, 0x1da33d0, 1, 0x7ffc36ff7e40, 0x7ffc36ff7e3c, 0x7ffc36ff7e50, 512, 0x7ffc36ff7e3a) error.c:559:SQLGetDiagRec: "[FreeTDS][SQL Server]Invalid precision value" error_export.h:19:SQLGetDiagRecW(3, 0x1da33d0, 2, 0x7ffc36ff7e40, 0x7ffc36ff7e3c, 0x7ffc36ff7e50, 512, 0x7ffc36ff7e3a) error_export.h:19:SQLGetDiagRecW(3, 0x1da33d0, 1, 0x7f1d355838e0, 0x7f1d355838ec, 0x7f1d355834e0, 511, 0x7ffc36ff8ade) error.c:559:SQLGetDiagRec: "[FreeTDS][SQL Server]Invalid precision value" error_export.h:19:SQLGetDiagRecW(3, 0x1da33d0, 2, 0x7f1d355838e0, 0x7f1d355838ec, 0x7f1d355834e0, 511, 0x7ffc36ff8ade) odbc.c:4259:SQLFreeStmt(0x1da33d0, 0)

as per logs SQL_NUMERIC using scale 3 which causes for the issue, but am not sure how we can avoid from this exception, Could you please help on this issue.

Thanks in advance.

v-chojas commented 6 months ago

255 doesn't sound like the right precision for a numeric... but this has nothing to do with unixODBC. Check your application.

lurcher commented 6 months ago

On 20/03/2024 14:37, kothapraveen wrote:

Hi Team, Currently we are facing below Exception, when we execute the statement query.

Hmm, well:

  1. We are not a team, we are a group of people with a common interest in ODBC, but don't assume that we are here to provide support desk type of anything for anything, and certainly not in this case, as its nothing to do with the subject of this project.

  2. The clue is in the error. "FreeTDS" there may be FreeTDS folk here, but again FreeTDS is the place to ask questions about FreeTDS. This project is not FreeTDS.

  3. As you have been told, that bind is telling the driver to treat the database side type of that column as a NUMERIC( 255, 3 ). The likely max precision of a ODBC numeric is 15 looking at the MS Docs for SQL Server. Your application is doing something wrong.