# Data Record Loop

{% hint style="info" %}
**Block Information**

Available in: Page Flow and Cloud Flow

Toolbox Category: Data

Block Type: [Regular](https://docs.zingy.ai/app-editor/block-anatomy#regular-block)
{% endhint %}

**`Data Record Loop`** is a [regular block](https://docs.zingy.ai/app-editor/block-anatomy#regular-block) that allows you to iterate over all the [records](https://docs.zingy.ai/data/database-tables#table-records) retrieved, after a successful read operation, by the [Data Read](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read), [Data Read Next Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-next) and [Data Read Previous Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-previous) blocks.

{% hint style="warning" %}
NOTE: This block will provide valid values only after the [Data Read](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read), [Data Read Next Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-next) and [Data Read Previous Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-previous) blocks complete their execution. The [Data Status](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-status) block can be used to track the completion.
{% endhint %}

<div align="left"><figure><img src="https://3401585094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmnBepgycwgisXr9ya1N4%2Fuploads%2FexbTctyjuiWEcuzhABor%2Fimage.png?alt=media&#x26;token=c2dcc1f4-befd-433b-b34f-84ec0cc46eff" alt="" width="448"><figcaption><p>Data Record Loop block</p></figcaption></figure></div>

The block consists of the following (from top to bottom):

* *Table:* [Value Parameter](https://docs.zingy.ai/app-editor/block-anatomy#value-parameters) that accepts a [*text*](https://docs.zingy.ai/app-editor/page-flow/references/value-types) value representing the name of the [Database Table](https://docs.zingy.ai/app-editor/data/database-tables) .
* *Dataset Name:* [Value Parameter](https://docs.zingy.ai/app-editor/block-anatomy#value-parameters) that accepts a [*text*](https://docs.zingy.ai/app-editor/page-flow/references/value-types) value representing the name of the dataset on which a database read was conducted using the [Data Read](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read), [Data Read Next Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-next) and [Data Read Previous Page](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read-previous) blocks.
* *Tasks*: a [Flow Parameter](https://docs.zingy.ai/app-editor/block-anatomy#flow-parameters) where you connect blocks that specify what you want done with each record. Use the [Data Record Info](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-info) and [Data Record Loop Index](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-loop-index) blocks here to access the record information for each iteration.

***

## Usage Example

{% hint style="info" %}
**NOTE: Please refer to the prerequisite information shown** [**here**](https://docs.zingy.ai/app-editor/page-flow/references/prerequisite-for-data-examples) **before seeing the example.**&#x20;
{% endhint %}

The image below shows an example of the **`Data Record Loop`** block. This example incorporates the *Usage Example* function, as outlined in the [Database Reading Logic for examples section](https://docs.zingy.ai/app-editor/references/prerequisite-for-data-examples#database-reading-logic-for-examples) on the prerequisite information page mentioned above.

<figure><img src="https://3401585094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmnBepgycwgisXr9ya1N4%2Fuploads%2FhQ1SoQrDMjNyXgEu2QGE%2Fimage.png?alt=media&#x26;token=8f094550-adac-49a0-87c1-73b2483d79d7" alt=""><figcaption><p>Example of Data Record Loop</p></figcaption></figure>

Here is a summary of the above example:

* The **`Data Record Loop`** block is used with the *Customers* [Database Table](https://docs.zingy.ai/app-editor/data/database-tables) and the dataset name of *ds1* are as [Value Parameters](https://docs.zingy.ai/app-editor/block-anatomy#value-parameters) .
* For each iteration inside the *Tasks* [Flow Parameter](https://docs.zingy.ai/app-editor/block-anatomy#flow-parameters), we use the [Write Log Message](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/write-log-message) block to log the customer's full name by accessing the *FirstName* and *LastName* fields of each record and combining them.
* To access information about the record, we use the [Data Record Info](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-info) block.
* For the *FirstName* and *LastName* fields we use the [Get Object Property](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/get-object-property) block.

The result for the above example can be seen in the [browser's web console](https://developer.chrome.com/docs/devtools/console/), and a sample is shown below:

```log
[LOG(info) 08/29/2023 10:39:29.413] John Smith
[LOG(info) 08/29/2023 10:39:29.415] Jane Smith
[LOG(info) 08/29/2023 10:39:29.415] Max Mustermann
[LOG(info) 08/29/2023 10:39:29.415] Joe Bloggs
```
