Sample UDX CMyProduct

The following sample UDX product takes two integers as input and multiples them to create a resulting product.

A sample create statement

CREATE OR REPLACE FUNCTION myproduct(INTEGER,INTEGER) RETURNS INTEGER
LANGUAGE CPP PARAMETER STYLE NPSGENERIC DETERMINISTIC
NO SQL NO EXTERNAL ACTION NOT FENCED CALLED ON NULL INPUT
EXTERNAL '/home/myuser/cpp/myprod!CMyProduct';
Note: For the external name, you must specify an absolute pathname to the object file unless the object file is in the samples/functions directory.

An example of a simple UDX source file:

#include "udxinc.h"

using namespace nz::udx_ver2;

class CMyProduct: public nz::udx_ver2::Udf
{
public:
    CMyProduct(UdxInit *pInit) : Udf(pInit)
    {
    }
    static nz::udx_ver2::Udf* instantiate(UdxInit *pInit);
    virtual nz::udx_ver2::ReturnValue evaluate()
    {
        int int1= int32Arg(0);
        int int2= int32Arg(1);

        int retVal = int1 * int2;

        NZ_UDX_RETURN_INT32(retVal);
    }
};
nz::udx_ver2::Udf* CMyProduct::instantiate(UdxInit *pInit)
{
    return new CMyProduct(pInit);
}