Name
<sql:query>
Synopsis
The <sql:query>
action executes an SQL
SELECT
statement
and saves the result in a scoped variable. The statement may contain
question marks as placeholders for values assigned by nested
<sql:param> actions.
The action uses a connection provided by an
<sql:transaction> action, or
transaction action or -- if not part of a
transaction -- from the explicitly specified data source or the
data-source configuration setting. The number of rows to retrieve can
be limited explicitly or with the maximum rows configuration setting.
Syntax 1: Without a body
<sql:query sql="sqlSelectStatement" [dataSource="dataSource"] [maxRows="maxRows"] [startRow="index"] var="var" [scope="page|request|session|application"] />
Syntax 2: With a body for parameters
<sql:query sql="sqlSelectStatement" [dataSource="dataSource"] [maxRows="maxRows"] [startRow="index"] var="var" [scope="page|request|session|application"]><sql:param> actions</sql:query>
Syntax 3: With a body for the statement and parameters
<sql:query [dataSource="dataSource"] [maxRows="maxRows"] [startRow="index"] var="var" [scope="page|request|session|application"]>sqlSelectStatement<sql:param> actions</sql:query>
Attributes
|
Attributename |
Java type |
Dynamic valueaccepted |
Description |
|---|---|---|---|
sql |
|
Yes |
The SQL statement. |
dataSource |
|
Yes |
The data source to use. If specified as a |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access