Skip to content
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

About “The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream” #171

Closed
rabbit-mom opened this issue Mar 6, 2017 · 7 comments
Labels
Waiting for Response Waiting for a reply from the original poster, or affiliated party

Comments

@rabbit-mom
Copy link

when I using TVP to bulkinsert to a table,this exception occured,and I do not konw to solve it?
"com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Table-valued parameter 0 (""), row 0, column 0: Data type 0x6C has an invalid precision or scale."
What reason is this?How to solve it?

@gordthompson
Copy link
Contributor

Can you provide a Minimal, Complete, and Verifiable example?

@rabbit-mom
Copy link
Author

Hi,thanks for your response,next is my example:

SQLServerDataTable sourceDataTable=new SQLServerDataTable();
sourceDataTable.addColumnMetadata("actuAmount",Types.DECIMAL);
sourceDataTable.addColumnMetadata("amount",Types.DECIMAL);
sourceDataTable.addRow(new BigDecimal(0.0000).setScale(4,BigDecimal.ROUND_HALF_UP),new BigDecimal(1098.0000).setScale(4,BigDecimal.ROUND_HALF_UP));
SQLServerCallableStatement pStmt = (SQLServerCallableStatement) DataSource.getConnection("DBName").prepareCall("exec spT_TbaleA_i ?");
pStmt.setStructured(1,"TVP_TbaleA",sourceDataTable);
pStmt.execute();

I found the problem is at "new BigDecimal(0.0000).setScale(4,BigDecimal.ROUND_HALF_UP)",the precision is four and the value is 0.0000,it will throws that exception.Eagerly looking forward to your reply.

@gordthompson
Copy link
Contributor

I can reproduce the issue using the above Java code along with

CREATE TYPE [dbo].[TVP_TbaleA] AS TABLE(
    [c1] [decimal](18, 4) NOT NULL,
    [c2] [decimal](18, 4) NULL,
    PRIMARY KEY CLUSTERED 
(
    [c1] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)

and

CREATE PROCEDURE [dbo].[spT_TbaleA_i] 
    @tbl dbo.TVP_TbaleA READONLY
AS
BEGIN
    SET NOCOUNT ON;
    SELECT c1 + c2 AS cSum FROM @tbl;
END

As decribed, it is the

new BigDecimal(0.0000).setScale(4,BigDecimal.ROUND_HALF_UP)

argument to SQLServerDataTable#addRow that is causing the exception. Both

new BigDecimal(1.0000).setScale(4,BigDecimal.ROUND_HALF_UP)

and

new BigDecimal(0.0000)

work fine.

@xiangyushawn
Copy link
Contributor

@rabbit-mom which version of the driver do you use? could you please try with a newer version? This bug seems to be fixed since 6.1.2

@xiangyushawn xiangyushawn added the Waiting for Response Waiting for a reply from the original poster, or affiliated party label Mar 7, 2017
@gordthompson
Copy link
Contributor

gordthompson commented Mar 7, 2017

My repro above was with the latest production release: 6.0.8112.100

Re-tested with version 6.1.4 and the error did not occur, so this appears to be the same issue as #92.

@xiangyushawn
Copy link
Contributor

xiangyushawn commented Mar 7, 2017

@gordthompson thank you for getting back to us and confirming with us. I am going to close this issue then. @rabbit-mom please free feel to re-open the issue if you see this issue again with newer version of the driver. Thank you.

@rabbit-mom
Copy link
Author

Thank you very much, the problem has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting for Response Waiting for a reply from the original poster, or affiliated party
Projects
None yet
Development

No branches or pull requests

3 participants