# SPIDER\_BG\_DIRECT\_SQL

## Syntax

```
SPIDER_BG_DIRECT_SQL('sql', 'tmp_table_list', 'parameters')
```

## Description

Executes the given SQL statement in the background on the remote server, as defined in the parameters listing. If the query returns a result-set, it sttores the results in the given temporary table. When the given SQL statement executes successfully, this function returns the number of called UDF's. It returns `0` when the given SQL statement fails.

This function is a [UDF](https://mariadb.com/docs/server/server-usage/user-defined-functions) installed with the [Spider](https://mariadb.com/docs/server/server-usage/storage-engines/spider) storage engine.

## Examples

```sql
SELECT SPIDER_BG_DIRECT_SQL('SELECT * FROM example_table',  '', 
   'srv "node1", port "8607"') AS "Direct Query";
+--------------+
| Direct Query | 
+--------------+
|            1 |
+--------------+
```

## Parameters

#### `error_rw_mode`

* Description: Returns empty results on network error.
  * `0` : Return error on getting network error.
  * `1`: Return 0 records on getting network error.
* Default Table Value: `0`
* DSN Parameter Name: `erwm`

## See also

* [SPIDER\_DIRECT\_SQL](https://mariadb.com/docs/server/server-usage/storage-engines/spider/spider-functions/spider_direct_sql)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# 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://mariadb.com/docs/server/server-usage/storage-engines/spider/spider-functions/spider_bg_direct_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.
