Iterators
If you create an iterator method that returns a set one row at a time, BladeSmith adds code to process the set. The HCL OneDB™ database server calls iterator methods repeatedly to process all of the return values.
The generated code
Flag value | Description |
---|---|
UDR_SET_INIT |
The initial call to the iterator method. The iterator method allocates and initializes memory for state information. |
UDR_SET_RETONE |
The iterator method is called with this request
flag once for each value in the set. For each value in the set, the method places the address of the next value in the set in the Gen_RetVal argument and returns Gen_RetVal. When there are no more values to return, the iterator method must call the setSetIterationIsDone() function to signal the HCL OneDB database server that all of the set values have been returned. |
UDR_SET_END |
The request flag the HCL OneDB database server sets after all values in the set have been returned. The iterator method frees allocated memory and releases any other resources it has obtained. |
In the generated code, each of these sections has a TO
DO:
note. To avoid code merging problems, only change sections
where indicated.
Complete the code
- Add information declarations.
- Initialize the iterator function.
- Allocate private state information.
- Compute the value of the iteration.
- Call setSetIterationIsDone() when the iteration is complete.
- Free private resources.
For more information about programming iterator methods, see HCL® J/Foundation Developer's Guide.