Run the stringpad UDFs
After you create the C++ programs that contain your SPUPad calls, you compile them by using nzudxcompile and register them on the Netezza Performance Server system. For an example of the CREATE [OR REPLACE] FUNCTION commands to register these sample UDFs, see The string_pad_create.cpp sample program and The string_pad_get.cpp sample program. These functions can easily be saved in one C++ program; after you compile the program, you would use the CREATE [OR REPLACE] FUNCTION command to register each of the functions as separate UDFs.
After you compile and register the UDFs, you can run them. For example, the following sequence of commands that is entered at the nzsql prompt show how these functions process the data. The commands are processed within a BEGIN/COMMIT transaction block so that the SPUPad still exists for the string_pad_get function.
MYDB.SCHEMA(MYUSER)=> BEGIN TRANSACTION;
BEGIN
MYDB.SCHEMA(MYUSER)=> SELECT string_pad_create(10, 'netezza') FROM
one_dslice;
STRING_PAD_CREATE
-------------------
t
(1 row)
MYDB.SCHEMA(MYUSER)=> SELECT string_pad_get(0) FROM one_dslice;
STRING_PAD_GET
----------------
n
(1 row)
MYDB.SCHEMA(MYUSER)=> SELECT string_pad_get(1) FROM one_dslice;
STRING_PAD_GET
----------------
e
(1 row)
MYDB.SCHEMA(MYUSER)=> SELECT string_pad_get(2) FROM one_dslice;
STRING_PAD_GET
----------------
t
(1 row)
MYDB.SCHEMA(MYUSER)=> COMMIT;
COMMIT
MYDB.SCHEMA(MYUSER)=> select string_pad_get(0) from one_dslice; ERROR: Pad does not exist