The sample tpf_rg_1 is included in a precompiled dynamic library called libv4apiex (extension is platform-dependent). Its implementation is in the samples directory in tpf_rg_1.cxx.
Declare the TPF to the server.
CREATE OR REPLACE PROCEDURE tpf_rg_1( IN tab TABLE( num INT ) )
RESULT( c1 INT )
EXTERNAL NAME 'tpf_rg_1@libv4apiex';
Declare a table to use as input to the TPF.
CREATE TABLE test_table( val int );
Insert rows into the table:
INSERT INTO test_table values(1);
INSERT INTO test_table values(2);
INSERT INTO test_table values(3);
COMMIT;
Select rows from the TPF.
The table test_table has three rows with values 1,2,3. The sum of these values is 6. The example generates 6 rows.
SELECT * from tpf_rg_1( TABLE( select val from test_table ) );
To see how the describe affects the behavior, issue a CREATE PROCEDURE statement that has a different schema than the schema the TPF publishes in the describe:
CREATE OR REPLACE PROCEDURE tpf_rg_1( IN tab TABLE( num INT, num2 INT ) )
RESULT( c1 INT )
EXTERNAL NAME 'tpf_rg_1@libv4apiex';
Select rows from the TPF:
// This will return an error that the number of columns in select list
does not match input table param schema
SELECT * from tpf_rg_1( TABLE( select val from test_table ) );