After you create your C++ file for your new UDF, compile the C++ file by using the nzudxcompile command. The command is in the /nz/kit/bin/adm directory. The compilation process creates the object files that run on the IBM® Netezza® host and on the Netezza SPUs.
nzudxcompile /home/nz/udx_files/customername.cpp
After you create the compiled object files, you must register the UDF with the Netezza system. You can register a user-defined function by using the CREATE FUNCTION command, as described in the next section.
nzudxcompile customername.cpp –o customername.o
–-sig "CustomerName(varchar(64000))" --version 2 –-return INT4
–-class CCustomerName –-user myuser –-pw password –-db mydb
In this example, the double quotation marks are required to ensure that the shell properly handles the parentheses characters. This example also shows that you must include the --version 2 syntax when you are using the command to compile and register an API version 2 UDF. The command adds the UDF to the default schema of the mydb database. For systems running 7.0.3 or later that support multiple schemas in a database, you can specify the schema where you want to register the UDF using the --schema option, as follows:
nzudxcompile customername.cpp –o customername.o
–-sig "CustomerName(varchar(64000))" --version 2 –-return INT4
–-class CCustomerName –-user myuser –-pw password –-db mydb
--schema my_schema