Cursor and Noncursor Functions

A cursor function can fetch returned values one by one by iterating the generated result set of returned values. Such a function is an implicitly iterated function.

A function that returns only one set of values (such as one or more columns from a single row of a table) is a noncursor function.

The Return clause is valid in a cursor function or in a noncursor function. In the following example, the Return clause can return zero (0) or one value in a noncursor function. In a cursor function, however, it returns more than one row from a table, and each returned row contains zero or one value:
RETURNING INT;
In the following example, the Return clause can return zero (0) or two values if it occurs in a noncursor function. In a cursor function, however, it returns more than one row from a table, and each returned row contains zero or two values:
RETURNING INT, INT;

In both of the preceding examples, the receiving function or program must be written appropriately to accept the information that the function returns.