# 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" %}
