<sql-query>
Performs a specified query, then invokes SUBTASKS once for each row in the result set. For each iteration of SUBTASKS, column values will be registered as request attributes both under (1) the column name (all uppercase), and (2) the column index (starting with 1).
| Name | XPath | Description | Reagent Type | Expected Type | Required |
|---|---|---|---|---|---|
| DATA_SOURCE | @data-source | The DataSource to use for executing the SQL. If omitted the request attribute under the name 'SqlAttributes.DATA_SOURCE' will be used | PHRASE | javax.sql.DataSource | No |
| CONNECTION | @connection |
** DEPRECATED ** since 1.0.1
Optional Connection object. The default is the value of the 'SqlAttributes.CONNECTION' request attribute (if specified) or null.
Use DATA_SOURCE instead |
PHRASE | java.sql.Connection | No |
| SQL | sql | The SQL query statement that will be executed. | PHRASE | java.lang.String | Yes |
| PARAMETERS | parameter/@value | The parameters (if any) for the PreparedStatement that will perform this query. | NODE_LIST | java.util.List | No |
| SUBTASKS | subtasks/* | The set of tasks that are children of this query task. | NODE_LIST | java.util.List | No |
| EMPTY_RESULT | empty-result/* | The set of tasks that will be executed if the query returns no results. | NODE_LIST | java.util.List | No |
Reads database connection information from a properties file, makes a connection, writes each name from the 'users' table to the screen:
SELECT user_name FROM users
${req(1)},