# Query

## Introduction

A query allows you to select a target based on specific criteria. You can associate a segment code with the query results and insert additional data into it. By customizing the search parameters, you can obtain query results tailored to your criteria for work items. A query consists of various conditions that define your search, bringing results in line with the set parameters.

### Query Creation Process

Example Query: Get Salesforce Accounts and print using **Debug**.

1. **Configure the Query:** Drag and drop a **Flow** action. Click **Configure** and provide a description for the flow (e.g., Get SF Accounts Information).

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F11RzfysrBYmtb43rfzIx%2Fimage.png?alt=media&#x26;token=0559176a-16f3-47bb-8a8e-dae7cfec7f34" alt=""><figcaption></figcaption></figure>

2. Drag and drop a **Query** action. Click **Configure**, select the **Source** as **Salesforce**, and **Object** as **Account**.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FjYOzUj4SRs3ZY0SNyEc3%2Fimage.png?alt=media&#x26;token=f100ca6e-3305-467a-80de-42c8e3d5e3f9" alt=""><figcaption></figcaption></figure>

3. In the configure query section, select **All fields** or choose individual Salesforce fields. Select **All Fields**.
4. **Preview the Results:** Click **Preview** from the **Configure Query** section. The Salesforce objects will be displayed as **Rows** in the **Result** section.
5. **Debug the Query:** Drag and drop a **Debug** action. Click **Configure** and define the variable.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FzqUOkuc1Ol3rKiJHby5B%2Fimage.png?alt=media&#x26;token=2a13710e-8478-4e83-b6d2-f07f4d5956d5" alt=""><figcaption></figcaption></figure>

6. Click the **fx** icon to access the schema, then drag and drop the **name** schema onto the debug panel. Select the correct **Name** field to display the Salesforce account names.

{% hint style="info" %}
**PRO TIP**

When using the **Debug** action, ensure you select the correct field schema to avoid confusion and ensure accurate data output.
{% endhint %}

#### Run the Integration:

7. Click the **Close** icon and **Save**.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2Fj21VpGNToQ4Njyi8hq1d%2Fimage.png?alt=media&#x26;token=d1ba531c-c07f-4e22-970a-0860a7474d82" alt=""><figcaption></figcaption></figure>

8. Click the **Run** icon to execute the integration.
9. The console will display the executed query and print the Salesforce Account Names.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2Fax0oWqep7V3d6vZnXdD7%2Fimage.png?alt=media&#x26;token=bb9ae4b0-6534-4dd4-ac6b-e69149adc519" alt=""><figcaption></figcaption></figure>

<details>

<summary>Frequently Asked Questions (FAQ)</summary>

#### 1. Can I use multiple conditions in a single query?

Yes, you can create queries with various conditions to customize your search parameters and obtain results based on specific criteria.

#### 2. How do I preview the results of a query before executing it?

Click the 'Preview' option in the 'Configure Query' section to display all relevant objects in the results section before executing the query.

#### 3. What are the benefits of using queries in workflows?

Queries allow users to select targets based on criteria, customize search parameters, and associate segment codes with query results, enabling efficient data management and workflow automation.

#### 4. What are the different data sources I can query from?

You can query from various data sources, including Salesforce and other JDBC-compliant databases like MySQL, Oracle, and DB2.

#### 5. Can I combine data from multiple objects or tables in a single query?

Yes, you can combine data from multiple objects or tables in a single query in DBSync Cloud Workflow, allowing you to pull and analyze data from different sources simultaneously.

</details>

## Related Content

* [Log Management](https://docs.mydbsync.com/cloud-workflow/dbsync-platform/administration/logs) - This section explains how to manage and view logs in DBSync, helping you troubleshoot and monitor integration processes.
* [Transformation Examples](https://docs.mydbsync.com/cloud-workflow/flow-builder/transform-and-write) - This page offers examples of how to use query transformations in your integration projects within DBSync.


---

# 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.mydbsync.com/cloud-workflow/create-your-workflow/actions/query.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.
