> For the complete documentation index, see [llms.txt](https://trillo.gitbook.io/trillo-workbench-lessons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trillo.gitbook.io/trillo-workbench-lessons/begin-code-lessons/dataiterator.md).

# DataIterator

In this example, the function code gets a page at a time. It counts total items and iterates until the last page is fetched.

### Code: /lessons/DataIterator

&#x20;DataIterator lets the function iterate through each record without having to deal with the next page fetch logic.&#x20;

Steps

1. Create a new function called DataIteratorLesson.java.
2. Create a DataIterator instance using the SQL template used in the previous lesson.
3. It will internally create a DataRequest object.
4. Set passed parameters into DataRequest of DataIterator.
5. Initialize the DataIterator.
6. Iterate through it until there are no more items.
7. Execute the function and examine the result.
