> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/generic/database-operations/get-data-db.md).

# Get Data(DB)

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to retrieve data from a Database table. The result is stored in the given dynamic variable for further use during test execution.

## Syntax

**Input Value**: `<DB IP/instance name/DB file path>;<DB port>;<DB username>;<DB password>;<DB name>;<Query>;<DB Number/DB Tags>;<querytype/warehouse>(Optional);<schema>(Optional)`

| Argument                                                 | Description                                                                                               |
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| <p>\<DB IP/instance name/DB file path><br>(Required)</p> | Provide the Database server location, instance name, or DB file path you want to use for retrieving data. |
| <p>\<DB port><br>(Required)</p>                          | Provide the port number you want to use for connecting with the Database.                                 |
| <p>\<DB username><br>(Required)</p>                      | Provide the username you want to use for Database access.                                                 |
| <p>\<DB Password><br>(Required)</p>                      | Provide the password associated with the username.                                                        |
| <p>\<DB name><br>(Required)</p>                          | Provide the name of the Database you want to connect with.                                                |
| <p>\<Query><br>(Required)</p>                            | Provide the SQL or Non-SQL query you want to execute.                                                     |
| <p>\<DB Number/DB Tags><br>(Required)</p>                | Provide the Database identifier you want to use for the connection.                                       |
| <p>\<querytype/warehouse><br>(Optional)</p>              | Provide the data container you want to target within the Database.                                        |
| <p>\<schema><br>(Optional)</p>                           | Provide the schema you want to use.                                                                       |

{% hint style="info" %}
**Note**:

* When providing the database connection details, you must provide the **Database IP address**, the **instance name**, or the **Database file path** in the input value.
* When you are providing the database identifier, you must provide the **Database Number** or the **Database Tags** in the input value, as required.
* When you are using a non-SQL query, you must provide the **querytype** or the **warehouse name** in the input value.
  {% endhint %}

**Output Value**: `<Dynamic Variable>;<Dynamic Variable>(Optional)`

| Argument                                 | Description                                                                                           |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| <p>\<Dynamic Variable><br>(Required)</p> | This dynamic variable stores the data fetched from the Database.                                      |
| <p>\<Dynamic Variable><br>(Optional)</p> | <p>This dynamic variable stores the status as <strong>True</strong><br>or <strong>False</strong>.</p> |

### Example 1: Retrieving Data from a Database using the Get Data Action

In this example, we are explain how to retrieve data from a Database using the provided connection details and query.

* **Action**: Get Data(DB)
* **Input Value**: ep-lively-glitter-awuj6 pooler.estayd2.are.brown.tech;5472;browndb\_owner;bpg\_6sd0fCE2dBw;dvdrenl;SELECT \* FROM district WHERE district ILIKE 'Rajbari';14
  * The first argument (**ep-lively-glitter-awuj6 pooler.estayd2.are.brown.tech**) specifies the Database server hostname.
  * The second argument (**5472**) specifies the port number used to establish the Database connection.
  * The third argument (**browndb\_owner**) specifies the Database username.
  * The fourth argument (**bpg\_6sd0fCE2dBw**) specifies the Database password.
  * The fifth argument (**dvdrenl**) specifies the Database name.
  * The sixth argument **(SELECT \* FROM district WHERE district ILIKE 'Rajbari')** contains the SQL query to execute.
  * The seventh argument (**14**) specifies the Database number used for execution.
* **Output Value**: {DB\_Data}
  * The retrieved data from the Database is stored in the **{DB\_Data}** dynamic variable.
  * If a second output variable is defined, it stores the action status with the following possible values:
    * **True**: If the data is retrieved successfully.
    * **False**: If the data is not retrieved successfully.
* **Logical Explanation**: The **Get Data (DB)** action reads the value from the **Input Value** column (**ep-lively-glitter-awuj6 pooler.estayd2.are.brown.tech;5472;browndb\_owner;bpg\_6sd0fCE2dBw;dvdrenl;SELECT \* FROM district WHERE district ILIKE 'Rajbari';14**). The action establishes a connection using the given Database credentials and executes the SQL query. The retrieved data is stored in the **{DB\_Data}** variable.

{% hint style="info" %}
**Note**: If you want to display the stored data, use the **Display Variable Value** action. In the **Input Value** column, provide the value in array format: **{VariableName\[row number]\[column number]}**.
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2F9O64rrDniMloxYIkb3S3%2Fimage.png?alt=media&amp;token=428a2d21-33ce-43d8-a994-612b8169d642" alt=""><figcaption></figcaption></figure>

### Example 2: Retrieving Data from an IBM i DB Database using the Get Data Action

In this example, we explain how to retrieve customer records from an IBM DB database using the provided connection details and SQL query.

* **Action:** Get Data (DB)
* **Input Value:** 10.13.0.62;9471;John;John$QA\@12;;SELECT \* FROM SALESDB.CUSTOMERS;16
  * The first argument (**10.13.0.62**) specifies the IP address of the IBM DB server.
  * The second argument (**9471**) specifies the port number used to establish the database connection.
  * The third argument (**John**) specifies the database username.
  * The fourth argument (**John$QA\@12**) specifies the database password.
  * The fifth argument is left empty because no database name is provided in this example.
  * The sixth argument (**SELECT \* FROM SALESDB.CUSTOMERS**) contains the SQL query used to retrieve all records from the **CUSTOMERS** table in the **SALESDB** schema.
  * The seventh argument (**16**) specifies the database number used for execution.
* **Output Value:** {DB\_Data}
  * The retrieved customer records from the database are stored in the **{DB\_Data}** dynamic variable.
  * If a second output variable is defined, it stores the Action status with the following possible values:
    * **True:** If the customer records are retrieved successfully.
    * **False:** If the customer records are not retrieved successfully.
* **Logical Explanation:** The **Get Data (DB)** Action reads the connection details and SQL query from the **Input Value** column. It uses the provided IBM DB server IP address, port number, username, password, and database number to establish a database connection. The Action then executes the SQL query **SELECT \* FROM SALESDB.CUSTOMERS** to retrieve all records from the **CUSTOMERS** table in the **SALESDB** schema. The retrieved records are stored in the **{DB\_Data}** dynamic variable.

{% hint style="info" %}
**Note:** To display the retrieved data, use the **Display Variable Value** Action. In the **Input Value** column, provide the variable in the following array format: **{VariableName\[row number]\[column number]}**. For example, {DB\_Data\[0]\[0]} refers to the value in the first row and first column of the retrieved data.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avoautomation.com/avo-assure/actions/generic/database-operations/get-data-db.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
