Sample UDX: Add 5 to Input
The following sample UDX adds a value of 5 to an input integer. It defines a separate class for each type of input (smallint, bigint, and integer).
The input source file:
#include "udxinc.h"
using namespace nz::udx_ver2;
extern "C" void * MyProductinstantiate(UdxInit *pInit);
// =======================================================
class add5toSmallint: public nz::udx_ver2::Udf
{
public:
add5toSmallint(UdxInit *pInit) : Udf(pInit)
{
}
static nz::udx_ver2::Udf* instantiate(UdxInit *pInit);
virtual nz::udx_ver2::ReturnValue evaluate()
{
int16 int16Input = int16Arg(0);
int16 int16Ret = 0;
int16Ret = int16Input + 5;
setReturnNull(false);
NZ_UDX_RETURN_INT16(int16Ret);
}
};
nz::udx_ver2::Udf* add5toSmallint::instantiate(UdxInit *pInit)
{
return new add5toSmallint(pInit);
}
// =======================================================
class add5toInteger: public nz::udx_ver2::Udf
{
public:
add5toInteger(UdxInit *pInit) : Udf(pInit)
{
}
static nz::udx_ver2::Udf* instantiate(UdxInit *pInit);
virtual nz::udx_ver2::ReturnValue evaluate()
{
int32 int32Input = int32Arg(0);
int32 int32Ret = 0;
int32Ret = int32Input + 5;
setReturnNull(false);
NZ_UDX_RETURN_INT32(int32Ret);
}
};
nz::udx_ver2::Udf* add5toInteger::instantiate(UdxInit *pInit)
{
return new add5toInteger(pInit);
}
// =======================================================
class add5toBigint: public nz::udx_ver2::Udf
{
public:
add5toBigint(UdxInit *pInit) : Udf(pInit)
{
}
static nz::udx_ver2::Udf* instantiate(UdxInit *pInit);
virtual nz::udx_ver2::ReturnValue evaluate()
{
int64 int64Input = int64Arg(0);
int64 int64Ret = 0;
int64Ret = int64Input + 5;
setReturnNull(false);
NZ_UDX_RETURN_INT64(int64Ret);
}
};
nz::udx_ver2::Udf* add5toBigint::instantiate(UdxInit *pInit)
{
return new add5toBigint(pInit);
}