Return one active-set item
When the iterator status is SET_RETONE, the iterator function can return one item of the active set. When the iterator function obtains this iterator-status value, it can perform the iteration tasks needed to generate one item of the active set.
You can perform these iterator tasks directly in the iterator function or you can declare a separate iterator-value-return function, which the iterator function calls when it receives the SET_RETONE iterator-status value. Declare the iterator-value-return function to return the same data type as the main iterator function. The database server puts the return value of this function in the active set.
Each item in the active set that the fibGen() function generates is one call to the fibGen_retone() function. The fibGen_retone() function returns one number of the Fibonacci series. It uses the mi_fp_funcstate() function to obtain the user-state pointer from the MI_FPARAM structure. This user-state pointer points to a fibstate structure (which the fibGen_init() function in The fibGen_init() initialization function allocated).
From the information in the fibstate structure, the fibGen_retone() function determines the next Fibonacci number and stores it in the next variable. The function then updates the fibstate structure for the next iteration of fibGen(). Finally, the function returns one item of the active set: the value of next.