> For the complete documentation index, see [llms.txt](https://docs.pentaho.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pentaho.com/pdia-data-integration/pdi-transformation-steps-reference-overview/execute-row-sql-script-cp.md).

# Execute Row SQL Script

The **Execute row SQL script** step executes an SQL statement or file for every input row, allowing you to dynamically assemble SQL for the creation of indexes, partitions, and tables.

{% hint style="info" %}
Prepared SQL statements are not used due to the scripting and dynamic operation of this step, which can slow transformation performance.

For better performance, use dedicated steps like [Table Output](/pdia-data-integration/pdi-transformation-steps-reference-overview/table-output.md), [Table Input](/pdia-data-integration/pdi-transformation-steps-reference-overview/table-input.md), [Update](http://wiki.pentaho.com/display/EAI/Update), and [Delete](/pdia-data-integration/pdi-transformation-steps-reference-overview/delete-step-pdi.md).
{% endhint %}

### General

| Field                       | Description                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **Step name**               | Specify the unique name of the Execute row SQL script step on the canvas. You can customize the name or leave it as the default. |
| **Connection**              | Select a database connection.                                                                                                    |
| **Edit**                    | Edit your current database connection.                                                                                           |
| **New**                     | Create a new database connection.                                                                                                |
| **Wizard**                  | Create a new database connection using the wizard.                                                                               |
| **Commit**                  | Number of rows to commit at a time. Default: `1`.                                                                                |
| **Send a single statement** | Clear if you do not want to group rows into a single statement.                                                                  |
| **SQL field name**          | Field that contains either the SQL statement or the path to the SQL file to execute.                                             |
| **Read SQL from file**      | Select if **SQL field name** contains a path to an SQL file.                                                                     |

### Output fields

![Execute Row SQL Script Output Fields](https://773338310-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYwnJ6Fexn4LZwKRHghPK%2Fuploads%2Fgit-blob-93bb9cb48658cd5179a7ff5c47aa2254b1d5028c%2FPDI_TransStep_Execute_Row_SQL_Script_Dialog.png?alt=media)

The Execute row SQL script step includes the following output field options for collecting statistics about script processing:

| Option                            | Description                                                            |
| --------------------------------- | ---------------------------------------------------------------------- |
| **Field to contain insert stats** | Name of the output field that contains the number of records inserted. |
| **Field to contain update stats** | Name of the output field that contains the number of records updated.  |
| **Field to contain delete stats** | Name of the output field that contains the number of records deleted.  |
| **Field to contain read stats**   | Name of the output field that contains the number of records read.     |

### Metadata injection support

All fields in this step support metadata injection. You can use this step with [ETL metadata injection](/pdia-data-integration/pdi-transformation-steps-reference-overview/etl-metadata-injection.md) to pass metadata to your transformation at runtime.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pentaho.com/pdia-data-integration/pdi-transformation-steps-reference-overview/execute-row-sql-script-cp.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
