Passing a user-defined table type to a SQL Server stored procedure using JDBC

前端 未结 2 476
星月不相逢
星月不相逢 2020-12-06 22:11

We\'ve got this User-Defined-Table Type in SQL Server:

CREATE TYPE [dbo].[INITVALS_MSG] AS TABLE(
    [SDate] [decimal](8, 0) NOT NULL,
    [EDate] [decimal]         


        
2条回答
  •  隐瞒了意图╮
    2020-12-06 22:30

    Try it this way:

    connection = dataSource.getConnection();
    CallableStatement statement = connection.prepareCall("{? = call dbo.RegisterInitAssets(?)}");
    statement.registerOutParameter(1, OracleTypes.CURSOR);//you can skip this if procedure won't return anything
    statement.setObject(2, new InitvalsMsg()); //I hope you some kind of representation of this table in your project
    statement.execute();
    
    ResultSet set = (ResultSet) statement.getObject(1);//skip it too if its not returning anything
    

提交回复
热议问题