-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TVP varchar(max) fails with ISQLServerDataRecord, works with SQLServerDataTable #846
Comments
hi @dangets, Thank you for providing the repro code we will look into this and update you on our findings. |
For sure! I can rewrite in Java if it would be more helpful. |
hi @dangets I was able to make this work by specifying the precision of the column in SQLServerMetaData in getColumnMetaData(). In this case that is the length of the string in the row you are adding. In the case of SQLServerDataTable, the addRow() method fills in the precision for SQLServerMetaData when adding the string, so getColumnMetaData() needs to do the same when constructing the SQLServerMetaData. This is because the driver needs to know the length/precision of the data so it can send the appropriate header to the server. Please see https://static.javadoc.io/com.microsoft.sqlserver/mssql-jdbc/6.1.6.jre8-preview/com/microsoft/sqlserver/jdbc/SQLServerMetaData.html constructor for SQLServerMetaData which also includes precision:
So in your example, if you change to:
Then both methods would produce the same results. Hope this helps, let me know if you have more questions. |
The workaround does help, thank you. It still seems like this could/should be something handled by the driver code itself though, and would be more friendly & consistent with the Otherwise, I would ask that this edge case be documented somewhere like https://docs.microsoft.com/en-us/sql/connect/jdbc/using-table-valued-parameters?view=sql-server-2017 or https://docs.microsoft.com/en-us/sql/connect/jdbc/using-advanced-data-types?view=sql-server-2017 |
hi @dangets, I agree it's a bit non-intuitive, we will look into improving and/or documenting this case. Thank you for your patience. |
Hi @dangets , |
Driver version
7.1.1.jre10-preview AND 6.2.2.jre8 (assuming all other versions too)
SQL Server version
Microsoft SQL Server 2014 (SP2-CU11) (KB4077063) - 12.0.5579.0 (X64)
Feb 21 2018 12:19:47
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.3 (Build 9600: )
Client Operating System
Ubuntu 18.04
JAVA/JVM version
10.0.2+13-1ubuntu0.18.04.2
Table schema
Problem description
Error thrown when trying to use TVP, with string column > 4000 characters. Using
SQLServerDataTable
works, butISQLServerDataRecord
fails. The code snippet below shows the usages. This relates to #250Error message is
The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Table-valued parameter 0 (""), row 1, column 1: Data type 0xE7 has an invalid data length or metadata length.
Reproduction code
Code is in Kotlin, but is nearly identical to java version.
The text was updated successfully, but these errors were encountered: