The sample tpf_rg_2 is included in a pre-compiled dynamic library called libv4apiex (extension is platform-dependent). Its implementation is in the samples directory in tpf_rg_2.cxx.
- Issue a CREATE PROCEDURE statement to declare the TPF to the server.
CREATE OR REPLACE PROCEDURE tpf_rg_2( IN tab TABLE( num INT ) )
RESULT( c1 INT )
EXTERNAL NAME 'tpf_rg_2@libv4apiex';
- Issue a CREATE TABLE statement to 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.
SELECT * FROM tpf_rg_2( TABLE( SELECT val FROM test_table ) );
The table test_table has three rows with values 1,2,3. The sum of these values is 6. The example generates 6 rows.