# cSQL

Reads from and writes to any database using a SQL connection based on a query.

For more information, see the Apache camel documentation https://camel.apache.org/components/latest/.

Information noteNote: This component is available only if you have installed the R2022-11 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.

## cSQL Standard properties

These properties are used to configure cSQL running in the Standard Route framework.

The Standard cSQL component belongs to the Connectivity family.

## Basic settings

| Properties | Description |
| --- | --- |
| Datasource | Select the component that opens the database connection to be<br>reused by this component. |
| Output Type | Select the type of the output data.<br><br><ul> <li><span>SelectOne</span>: Make the output as single Java                        object.</li> <li><span>SelectList</span>: Make the output as list of maps.</li> <li><span>StreamList</span>: Use an iterator to stream the                        output.</li> </ul> |
| Batch Mode | Select this checkbox to execute the statement in batch mode. |
| Use SQL statement from message body | Select this check box if your query statement is specified in the<br>message body. |
| Type | Select the source type of the SQL query. This option is not available if<br>Use SQL statement from message body is enabled.<br><br><ul> <li><span>Built-In</span>: The query statement will be entered                        directly within the component.</li> <li><span>Repository</span>: The query statement will be selected                        from an existing repository resource file.</li> <li><span>File Path</span>: The query statement will be selected from                        the local file system.</li> </ul> |
| Query | This option appears when Built-In is selected from<br>the Type list. Specify a database query statement, paying<br>particularly attention to the proper sequence of the fields which must correspond<br>to the schema definition.<br><br>If you have installed the R2025-12 Talend Studio Monthly update or a later one delivered by Talend, you can use multi-lines and format the SQL statement as you want. You can<br>also click [...] next to the<br>Query code box to open the SQL<br>Builder and create a query in it. For more information, see<br>[Creating queries using the<br>SQLBuilder](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/creating-queries-using-sqlbuilder). |
| Resource | This option appears when Repository is<br>selected from the Type list. Select the resource query<br>statement file from the repository. Select the version of the query statement<br>in the Version field if more than one version of the<br>query statement is available. |
| Resource File | This option appears when File Path is<br>selected from the Type list. Enter the path to the query<br>statement file in your local file system. |

## Advanced settings

| Properties | Description |
| --- | --- |
| Return generated keys from Inserts | Select this checkbox to retrieve the generated keys when inserting data into<br>a table configured with an auto-incrementing key using cSQL. The generated keys<br>are contained in the message header CamelSqlGeneratedKeyRows. For<br>more information on the message headers supported by cSQL, see [Message Headers](https://camel.apache.org/components/4.14.x/sql-component.html#_message_headers).<br><br>To specify which<br>generated columns should be retrieved, click [+] as many<br>times as required to add rows to the Expected keys table<br>and enter the column names.<br><br>Information noteNote: This option is available only if you have<br>installed the R2025-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator. |
| URI Options | Set the optional arguments in the corresponding table. Click [+] as many times as required to add arguments to the<br>table. In the Name field, you can either select the URI<br>option from the drop-down list, or enter an option name that is not available in<br>the list. Then click the corresponding Value<br>field and enter a value. See the site https://camel.apache.org/components/latest/sql-component.html for available URI options. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | cSQL can be a start, middle or end<br>component in a Route. It has to be used with the cSQLConnection component, which creates a connection to the<br>database. For more information about cSQLConnection, see [cSQLConnection](https://help.qlik.com/talend/en-US/components/8.0/mediation-database/csqlconnection). |
| Limitation | n/a |

**Related concepts**

* [Writing and reading data in an H2 database with an SQL statement](https://help.qlik.com/talend/en-US/mediation-components/8.0/mediation-database/csql-writing-and-reading-data-in-an-h2-database-with-an-sql-statement)