# SQL

### Introduction

The **SQL** Action in DBSync Cloud Workflow enables you to interact with databases directly within your integration flows. Use it to write custom SQL queries that retrieve, insert, update, or delete records in supported databases — whether cloud-based or on-premise.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FmFKNzSdXnUwpSG23loJa%2Funknown.jpeg?alt=media&#x26;token=b67aa093-39d5-4b41-927f-fb482a5ee796" alt=""><figcaption></figcaption></figure>

## Use Cases

* Fetch records from a database to feed into the data stream.
* Update records dynamically based on workflow logic.
* Insert new data from integrated apps.
* Delete outdated or unnecessary records.

## Key Features

* Works with any connected database (for example, MySQL, PostgreSQL, SQL Server, Oracle).
* Supports dynamic queries using Fx-enabled variables.
* Real-time query results or update counts.
* Customizable batch size for optimized performance.
* Code editor with SQL syntax highlighting.

## How to Configure SQL Action

#### **Step 1: Add SQL Action to the Flow**

1. In the Flow screen, drag the **SQL** action from the **Actions** palette on the left and drop into your flow.
2. Click **Configure** on the flow panel to configure the flow. Open the Cloud Workflow Development Studio.
3. Drag and drop the **SQL** Action into your flow.

#### **Step 2: Select a Data Source**

4. Choose a database from the Source dropdown.
5. Only connectors of type `Database` will be shown.

#### **Step 3: Write Your SQL Query**

6. Use the SQL editor (with CodeMirror) to build your query.
7. You can insert dynamic fields using the Fx Panel (right-hand side).

```
SELECT * FROM customers WHERE created_at > 'last_sync_date'
```

## Supported Query Types

| Query Type | Result                         |
| ---------- | ------------------------------ |
| SELECT     | Tabular output in data preview |
| INSERT     | Count of rows inserted         |
| UPDATE     | Count of rows updated          |
| DELETE     | Count of rows deleted          |

## Output & Execution

8. Preview the results. The data is displayed in a tabular format.
9. Click Run <img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FvCTzfmvakwzQ4icxEMo9%2Funknown.png?alt=media&#x26;token=282d8fd3-bc23-426f-a030-907f173acf5f" alt="" data-size="line"> to execute the integration and observe how the flow operates with the connected queries and variables.

## Batch Size

You can control processing by setting a custom Batch Size. Useful for large data syncs.

## Best Practices

* Use Query Preview before saving changes.
* Sanitize dynamic inputs using filters/validation.
* Keep queries optimized to avoid long-running transactions.
* Leverage batch control in high-volume flows.

## Troubleshooting

| Problem                    | Likely Cause                  | Solution                              |
| -------------------------- | ----------------------------- | ------------------------------------- |
| No results returned        | Filters too narrow            | Check query logic and variable values |
| Column not found           | Column name mismatch          | Check column names in database        |
| Access denied / auth error | Connector credentials invalid | Re-authenticate the connector         |

The **SQL** Action is a powerful addition to your DBSync Cloud Workflow, enabling direct and dynamic access to your databases within any flow. Use it to automate data syncing, enrichment, and control - all from a single visual interface.

<br>


---

# 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/2026_create-your-workflow/action/sql.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.
