Running the Sample TPF in tpf_rg_2

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.

  1. 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';
    
  2. Issue a CREATE TABLE statement to declare a table to use as input to the TPF.
    CREATE TABLE test_table( val INT );
    
  3. Insert rows into the table.
    INSERT INTO test_table VALUES(1);
    INSERT INTO test_table VALUES(2);
    INSERT INTO test_table VALUES(3);
    COMMIT;
    
  4. 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.