# SQL Executor

This component is used to execute single or multiple SQL queries on the target database. The component can be configured with SQL statements that will be executed against the target database. The results of the query are sent to other components for further processing. This component is useful for tasks such as data retrieval, data updates, and database schema modifications.

![](https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image211.png)

If Multiple Query attribute is checked, each query generates its own result data.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image212.png" alt=""><figcaption></figcaption></figure>

Otherwise, SQL Executor executes whole queries in a single statement. Whether those whole queries are acceptable depends on the database and jdbc driver. The sample below is the result to maria DB and with mysql jdbc driver.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image213.png" alt=""><figcaption></figcaption></figure>

## **Input**

&#x20;

<table><thead><tr><th width="230">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>System Id</td><td>Database system id</td></tr><tr><td>Use Data Structure?</td><td>Map query result as data structure?</td></tr><tr><td>Save To File?</td><td><p>Save the query result into a file backed up list?</p><p>This option is particularly useful when dealing with large record sizes. High volumes of records can lead to an OutOfMemory error, making this option a valuable tool for managing memory usage and avoiding potential issues.</p></td></tr><tr><td>Query</td><td><p>Query to be executed.</p><p>Multiple queries are allowed. Queries are separated by semi-colon.</p></td></tr><tr><td>Multiple Query?</td><td><p>If checked, Query data is parsed, delimited by semi colon, and executed one by one.</p><p>If unchecked, Query data is executed in one statement.</p></td></tr><tr><td>Query Type</td><td><p>Query type</p><p>Literal - the query is constructed as a literal.</p><p>Prepared - the query is constructed with ?.</p></td></tr><tr><td>Operation Type</td><td>Query or Stored procedure</td></tr><tr><td>Output Parameters</td><td>If operation type is procedure, output parameters can be assigned.</td></tr></tbody></table>

Query can be generated from table layout.

1\)     Choose a database.

2\)     Click generate (<img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image214.png" alt="" data-size="line">) button and generate query.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image215.png" alt="" width="563"><figcaption></figcaption></figure>

Query can contain parameters.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image216.png" alt="" width="563"><figcaption></figcaption></figure>

If Query Type is prepared,

!\[Graphical user interface, text, application

Description automatically generated]\(<https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image217.png>)

The query is converted into this sql.

| select \* from source where year = year(curdate()) and zone = ? and today = ? |
| ----------------------------------------------------------------------------- |

Otherwise, parameters are replaced with the real values and single quotation for string type values.

| select \* from source where year = year(curdate()) and zone = 'zone01' and today = '2023-03-01' |
| ----------------------------------------------------------------------------------------------- |

&#x20;

If Save To File is checked, and operation is select, then the result set is stored in a file. The list in the memory has the index information. It does not have the data. The real data is stored in a temporary file. This file is generated at the directory which java.io.tmpdir property points to with .fjs extension. The file is deleted after the list is garbage collected. If the expected record size of the input is huge, Save To File should be checked.

This component gets the database connection from the information of system id. But the connection info can be acquired through parameterized way out of ISM.

If these properties exist, this component use these properties instead of system id.

<table><thead><tr><th width="226">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>Connection String</td><td>Custom connection string</td></tr><tr><td>User ID</td><td>Custom user id</td></tr><tr><td>Password</td><td>Custom password</td></tr><tr><td>Driver Class</td><td>Custom JDBC driver class</td></tr></tbody></table>

Thiese custom properties can be used for the databases like FireBird or Cubrid which ISM does not support through System menu.

| <img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image218.png" alt="" data-size="line"> | <img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image219.png" alt="" data-size="line"> |
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| FireBird                                                                                                         | Cubrid                                                                                                           |

&#x20;

## **Output**

&#x20;

<table><thead><tr><th width="209">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>ResultCode</td><td>Error code from the database</td></tr><tr><td>ResultMessage</td><td>Error message from the database</td></tr><tr><td>ResultCount</td><td><p>Retrieved count for Select, Update/Insert/Delete count for Update/Insert/Delete operations.</p><p>If multiple queries are executed, ResultCount-<em>index_number</em> will be generated.</p><p>The index number starts from 0.</p></td></tr><tr><td>ResultArray</td><td><p>Retrieved data set.</p><p>If multiple queries are executed, ResultArray-<em>index_number</em> will be generated.</p></td></tr><tr><td>DataStructureId</td><td>Data structure id of the retrieved data set</td></tr></tbody></table>

If UseDataStructure property is yes, the result set is carried in this parameter - MyResult. The default name of this parameter is *DataStructureId* and is duplicate with another parameter. The name should be changed if this result set is used in mapping.

*DataStructureId -> other name*

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image220.png" alt="" width="563"><figcaption></figcaption></figure>

## **Example**

This example flow simply generates the result set.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image221.png" alt=""><figcaption></figcaption></figure>


---

# 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://ism-docs.xnarum.com/tasks/db/sql-executor.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.
