Compile the UDF
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 host and on the Netezza Performance Server SPUs.
- To compile the customername.cpp file and
create the output object files:
nzudxcompile /home/nz/udx_files/customername.cpp
- customername.o_x86
- The object file for the Netezza Performance Server host (i386 Linux® platform on x86).
- customername.o_spu10
- The object file for the Linux-based Rev10 SPUs on IBM® Netezza® 1000 and Netezza 100 models (formerly called Netezza Performance Server TwinFin and Skimmer systems).
After you create the compiled object files, you must register the UDF with the Netezza Performance Server 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 mydbIn 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