Register the iterator function
Register the iterator function with the CREATE FUNCTION
statement. The CREATE FUNCTION must include the ITERATOR routine modifier
to tell the database server that it must call the function until the
iterator-completion flag is set to 1
.
Tip: If your iterator function calls other functions
(such as an iteration-initialization function, iterator-value-return
function, or iterator-end function) to implement its iterations, you
do not have to register these other functions with the CREATE FUNCTION
statement.
The following CREATE FUNCTION statement registers the fibGen() iterator
function, which The fibGen() iterator
function defines,
in the database:
CREATE FUNCTION fibgen(arg INTEGER)
RETURNING INTEGER
WITH (ITERATOR)
EXTERNAL NAME "$USERFUNCDIR/fib.so"
LANGUAGE C;
This statement assumes that the object code for the fibGen() function is in the UNIX™ or Linux™ fib.so shared-object file in the directory that the USERFUNCDIR environment variable specifies. It also assumes that USERFUNCDIR was set in the server environment.
For more information about how to register a user-defined function, see Register a C UDR.