Database Custom Actions

<ora:sqlQuery>

The <ora:sqlQuery> action executes a SQL SELECT statement and makes the result available as a java.util.Vector of com.ora.jsp.sql.Row objects. The SQL statement is specified in the body of the action element. Placeholder characters (question marks) can be used in the statement and given values dynamically by nested value action elements (see Section 3.3.5 later in this appendix for details). The attributes supported by the <ora:sqlQuery> action are described in Table 3.16.

Table C-16. <ora:sqlQuery> Attributes

Attribute Name

Java Type

Request-TimeValue Accepted

Description

dataSource
String

No

Mandatory, unless used with <ora:sqlTransaction>. The name of the data source.

id
String

No

Mandatory. The name of the vector to hold the result.

scope
String

No

Optional. The scope for the result, one of page, request, session, or application. Default is page.

Example:

<%-- 
  Get all rows from a table where a column matches the value
  of a request parameter.
--%>
<ora:sqlQuery id="empDbInfo" dataSource="example">
  SELECT * FROM Employee 
    WHERE UserName = ?
  <ora:sqlStringValue param="userName" />
</ora:sqlQuery>

<ora:sqlTransaction>

The <ora:sqlTransaction> action is used to enclose other database action elements that together make up a database transaction: a set of database operations where all operations either fail or succeed. The attribute supported by this action is described in Table 3.17.

Table C-17. <ora:sqlTransaction>Attribute

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.