Skip to main content

I need to pass a list of unique ids to a stored procedure. The expectation is that the procedure would return all data rows from a table that are related to any of the given ids. Another approach would be to foreach over the list and call the procedure for each ID, but I'd rather not take the inevitable performance hit.

 

In other langauges this could be accomplished by passing in a table valued parameter and joining against it in the stored proc. I have found the documentation for utilizing user defined types for Oracle databases [here](https://docs.mulesoft.com/mule-runtime/3.8/database-connector-reference# jdbc-user-defined-data-types-udt) and [here](https://docs.mulesoft.com/mule-runtime/3.8/database-connector# passing-user-defined-data-types-to-stored-procedure) but have not been able to find any documentation regarding how to accomplish the same thing for SQL server.

 

I've tried various definitions based on the above documentation in the off chance that the same approach would work with SQL Server and just wasn't documented, but that hasn't been the case. I usually get an error like the following:

 

com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.

 

I believe this means the driver doesn't know how to translate the array in Mulesoft into a user defined table type in the database. Is it possible to use TVPs with SQL Server in Mulesoft?

6 respuestas
  1. 15 oct 2020, 21:38

    I couldn't got the sample code working until I added the java module to the solution. Once this is added it works/doesn't through and errors.I couldn't got the sample code working until I added the java module to the solution. Once this is added it works/doesn't through and errors.

0/9000