A generic table function is a table UDF where the output table is not specified when the UDF is defined. Instead, the output table is specified when the UDF is referenced. Different output table size and shape are possible for the same generic table function, depending on different input arguments.
Starting with Version 10.1, generic table functions are supported for the Java™ language.
To define a generic table function, use the CREATE FUNCTION statement, and specify the RETURNS GENERIC TABLE option. To use this option, you must specify the LANGUAGE JAVA and PARAMETER STYLE DB2GENERAL options.
CREATE FUNCTION csvRead (VARCHAR(255))
RETURNS GENERIC TABLE
EXTERNAL NAME 'UDFcsvReader!csvReadString'
LANGUAGE JAVA
PARAMETER STYLE DB2GENERAL
Select TX.*
From TABLE (csvRead('/TMP/data/userWebClicks.log'))
AS TX (USER INTEGER, LINK VARCHAR(100))
WHERE TX.LINK LIKE 'www.ibm.com%'
Select TX.*
From TABLE (csvRead('/TMP/data/customerWebClicks.log'))
AS TX (CUSTOMERID INTEGER, NAME VARCHAR(100), ADDRESS VARCHAR(100))'