Programming
HR
How to Pass a Table Valued Parameter to a T-SQL Function with jOOQ
['View All Posts Lukaseder', 'I Made Jooq']
Java, SQL and jOOQ.
CREATE TYPE u_number_table AS TABLE (column_value INTEGER); CREATE FUNCTION f_cross_multiply ( @numbers u_number_table READONLY ) RETURNS @result TABLE ( i1 INTEGER, i2 INTEGER, product INTEGER ) AS BEGIN INSERT INTO @result SELECT n1.column_value, n2.column_value, n1.column_value * n2.column_value FROM @numbers n1 CROSS JOIN @numbers n2 RETURN END Using native JDBC, it is possible to follow the table-valued parameters tutorials and use a com.microsoft.sqlserver.jdbc.SQLServerDataTable , but if you’re using jOOQ and its code generator, both the user-defined type and the function will have generated Java code for you to call easily: is a static-imported method that models an embedded call to a table-valued function (standalone calls are also possible) UNumberTableRecord is a record…