outputRow()
After each call to the processRow() method, if the
outputRow() method is defined, it is called until it returns null. This allows a
UDTF to output any number of rows efficiently. The outputRow() method is always
called with one parameter, which is the number of times outputRow() has been called
since the processRow() method was called.
Here is an example of using
outputRow() in combination with
processRow(). The processRow() method is called first and stores
the value of x in the rows_to_output variable. The Netezza database then
calls the outputRow() method until it returns null. On the first call, the
rownum argument has the value 1, the second call it has the value
2,
etc.function processRow(x)
rows_to_output = x
return null
end
function outputRow(rownum)
if rownum > rows_to_output then
return null
end
return { rownum }
end
Once the outputRow() method has returned null, the Netezza database then
calls the processRow() method again with the next row of data to be processed. The
outputRow() method must return data in exactly the same format as is allowed for
the processRow() method.
Even if the
processRow() method returns a result, the
outputRow() method is still called after each call to
processRow(). For
example:function processRow(x)
rows_to_output = x
return { 0 }
end
function outputRow(rownum)
if rownum > rows_to_output then
return null
end
return { rownum }
end