# Database Function

This action will execute a standard query function on an [active cursor](https://docs.mylinkconnect.com/actions-and-operations/database/query-collection-data).

<figure><img src="https://3974284760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZEstFBYh3uMutlup6ku%2Fuploads%2FZKeCztIt9dkFZBwPodb9%2Fimage.png?alt=media&#x26;token=bf603799-351c-4348-8150-6e4d5cc95b30" alt=""><figcaption></figcaption></figure>

### Settings

The action uses the following settings:

| Setting  | Description                                                                  | [Parsed](https://docs.mylinkconnect.com/actions-and-operations/dynamic-parsing) |
| -------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Function | The function to be executed                                                  | :no\_entry:                                                                     |
| Field    | The name of the field to be used as parameter for the function, if required. | :white\_check\_mark:                                                            |

### Remarks

This action will execute one of three different functions using an active query cursor. After the function is executed, the cursor is closed.

<table><thead><tr><th width="163">Function</th><th>Result</th></tr></thead><tbody><tr><td>Count</td><td>Will return the amount of elements returned by the query</td></tr><tr><td>Sum</td><td>Will sum all values in the specified field. Any field value that cannot be translated to a number will be threated as a zero.</td></tr><tr><td>Unique Values</td><td>Will return a model containing an array with all the unique values of the specified field.</td></tr></tbody></table>

{% hint style="warning" %}
Function execution does not rewind the current cursor. Using this action on a cursor that already moved may lead to incorrect values.
{% endhint %}

### Trigger

This action does not have any trigger.

### Variables

This action produces the following variables after being triggered:

| Variable                   | Description                          |
| -------------------------- | ------------------------------------ |
| database\_function\_result | The result of the function execution |

### Availability

### Availability

Channel specific availability follows the table below:

| Channel          | Availability     |
| ---------------- | ---------------- |
| Facebook         | Fully Available. |
| WhatsApp         | Fully Available. |
| SMS              | Fully Available. |
| Telegram         | Fully Available. |
| Web              | Fully Available. |
| Alexa            | Fully Available. |
| Google Assistant | Fully Available. |
| Slack            | Fully Available. |
| API              | Fully Available. |


---

# 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.mylinkconnect.com/actions-and-operations/database/database-function.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.
