Name

<sql:update>

Synopsis

The <sql:update> action executes an SQL statement that updates the database, such as an INSERT, UPDATE, or DELETE statement, and optionally saves the number of affected rows in a scoped variable. SQL DDL statements, such as CREATE TABLE, can also be executed with this action. The statement may contain question marks as placeholders for values assigned by nested <sql:param> and <sql:dateParam> actions.

The action uses a connection provided by an <sql:transaction> action, or—if not part of a transaction—from the explicitly specified data source or the data-source configuration setting.

Syntax 1: Without a body

<sql:update sql="sqlStatement" 
  [dataSource="dataSource"]
  [var="var" [scope="page|request|session|application"]] />

Syntax 2: With a body for parameters

<sql:update sql="sqlStatement"
  [dataSource="dataSource"]
  [var="var" [scope="page|request|session|application"]]>
  <sql:param> actions
</sql:update>

Syntax 3: With a body for the statement and parameters

<sql:update
  [dataSource="dataSource"]
  [var="var" [scope="page|request|session|application"]]>
  sqlStatement
                     <sql:param> actions
</sql:update>

Attributes

Attribute name

Java type

Dynamic value accepted

Description

sql
String

Yes

The SQL statement.

dataSource
String or javax.sql.DataSource

Yes

The data source to use. If specified as a String, it can be either a JNDI path or a list of JDBC parameters as described for the data-source configuration setting.

var
String

No

The variable name. The type is ...

Get JavaServer Pages, 3rd Edition 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.