# Data Read

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

Available in: Page Flow and Cloud Flow

Toolbox Category: Data - Read

Block Type: [Regular](/app-editor/page-flow/block-anatomy.md#regular-block)
{% endhint %}

**`Data Read`** is a [regular block](/app-editor/page-flow/block-anatomy.md#regular-block) that initiates a reading of [records](/app-editor/data/database-tables.md#table-records) from a [database table](/app-editor/data/database-tables.md).

<div align="left"><figure><img src="/files/47KItiLbJvpfL5QK7GnC" alt="" width="197"><figcaption><p>Data Read block</p></figcaption></figure></div>

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

* *Table:* [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*text*](/app-editor/page-flow/references/value-types.md) value representing the name of the [Database Table](/app-editor/data/database-tables.md) .
* *Query:* Optional [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*text*](/app-editor/page-flow/references/value-types.md) value representing the name of the [Database Query](/app-editor/data/database-queries.md) . If this is blank, the database is read without any search criteria and sorting rules.&#x20;
* *Dataset Name:* [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*text*](/app-editor/page-flow/references/value-types.md) value representing the name of the dataset. This can be any [*text*](/app-editor/page-flow/references/value-types.md) value and can later be used to track the completion of the read.
* *Per Page*: [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [numeric](/app-editor/page-flow/references/value-types.md) value containing the number of [records](/app-editor/data/database-tables.md#table-records) to be read. This number is preserved for subsequent usage of the [Data Read Next](/app-editor/page-flow/toolbox-blocks/data-read-next.md) and [Data Read Previous](/app-editor/page-flow/toolbox-blocks/data-read-previous.md) blocks when the same *Dataset Name* is used.
* *Input Criteria*: Optional [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts an [object](/app-editor/page-flow/references/value-types.md) value. This is required only if a database query is selected for the *Query* parameter above. If the query contains search criteria parameters, the pre-attached Object block automatically gets populated.

{% hint style="success" %}
**NOTE**:&#x20;

* This block initiates the database read, which will occur in the background. To track the status and to take an action upon completion of the read, use the [Data Status](/app-editor/page-flow/toolbox-blocks/data-status.md) block.&#x20;
* To access the records after a successful read, see [Data Record Count](/app-editor/page-flow/toolbox-blocks/data-record-count.md), [Data Record Loop](/app-editor/page-flow/toolbox-blocks/data-record-loop.md), [Data Record at Index](/app-editor/page-flow/toolbox-blocks/data-record-at-index.md) blocks.
  {% endhint %}

***

## Usage Examples

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

The image below shows our first example.

<div align="left"><figure><img src="/files/6T9gzRrD18mkXAqFUqu2" alt="" width="527"><figcaption><p>Data Read Example 1</p></figcaption></figure></div>

In the above example, we initiate a database read for the *Customers* table which we have discussed [here](/app-editor/page-flow/references/prerequisite-for-data-examples.md). The Data Status block is used to track the status, and here we use the same *Customers* table and the dataset name of *ds1*. Upon success, we invoke the function *Usage Example*. We will look at some sample implementations for the *Usage Example* function.

<div><figure><img src="/files/nm4wTQg0hUtgXCeQYHXC" alt=""><figcaption><p>(1) Show the number of records read using the Data Read Count block</p></figcaption></figure> <figure><img src="/files/U5I3WmGKjJeJLiWZ6pup" alt=""><figcaption><p>(2) Use the Data Record Loop block to iterate over all the records</p></figcaption></figure></div>

The above sample implementations are discussed in more detail [here](/app-editor/page-flow/toolbox-blocks/data-record-count.md#usage-example) and [here](/app-editor/page-flow/toolbox-blocks/data-record-loop.md#usage-example).

Now let's take a look at another example, this time we will use the *NameMatch* query that is defined for the *Customers* table and is discussed [here](/app-editor/page-flow/references/prerequisite-for-data-examples.md#sample-queries).

<figure><img src="/files/4n3Mxx9TXV1tsOFeEBhY" alt=""><figcaption><p>Data Read Example 2</p></figcaption></figure>

The optional *Input Criteria* parameter is attached to the Object block, which has one property *Input-1* with a value of *Smi*. Remember that the [*NameMatch* query](/app-editor/page-flow/references/prerequisite-for-data-examples.md#sample-queries) accepts one input parameter and will list records where either the *FirstName* or the *LastName* fields contains the given input.

Also note the sample records contained in the *Customers* database table provided [here](/app-editor/page-flow/references/prerequisite-for-data-examples.md#sample-records).

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/30/2023 17:29:52.179] Name: Jane Smith
[LOG(info) 08/30/2023 17:29:52.181] Name: John Smith
```

Since the *Input-1* parameter was set to the value *Smi*, the database read resulted in the records of Jane Smith and John Smith being shown.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-read.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
