StatementBatch: Direct SQL in Batch Mode
Input
In batch mode, the JDBC Iterator executes multiple SQL statements at the same time, if they are deposited in the following input XML structure. In this case, only SQL statements are possible, which do not return a ResultSet
, i.e. no queries with SELECT
:
<Any element name>
<statementbatch resulttag="Result element name" timezone="time zone"
format="date format">
<sql>
SQL statement 1
</sql>
<sql>
SQL statement n
</sql>
</statementbatch>
</Any element name>
The following rules apply to each <statementbatch/>
element:
The optional attribute
timezone
specifies a time zone according tojava.util.TimeZone
, e. g.GMT+2
, see http://docs.oracle.com/javase/1.5.0/docs/api/java/util/TimeZone.html.The optional attribute
format
specifies a date format according tojava.text.SimpleDateFormat
.It contains at least one
<sql/>
element that contains an SQL statement.
If you use characters within the SQL statement or for the values or data of the table columns that have a meaning in XML, mask the SQL statement with surrounding CDATA block, e.g. <![CDATA[ UPDATE PROCESS SET X4_VERSION=4 WHERE X4_DURATION=100 ]]>
or <rowset><row><name><!CDATA[
XML character “<“ in CDATA element]]></name></row></rowset>
.
This ensures that the characters in the CDATA element are not interpreted as XML, but as data for the adapter.
Example
<select>
<statementbatch resulttag="Result element name" timezone="UTC" format="dd.MM.yyyy">
<sql>
<![UPDATE PROCESS SET X4_VERSION=4 WHERE X4_DURATION=100]]>
</sql>
<sql>
<![UPDATE PROCESS SET X4_VERSION=4 WHERE X4_DURATION=200]]>
</sql>
</statementbatch>
</select>
Output
If the batch statement was executed successfully, the database connection element will output the following structure:
<Data>
<Result element name>
<!--Status of the batch operation-->
</Result element name>
</Data>
The following status outputs are possible for the batch operation:
(Number or rows) rows affected.
SUCCESS_NO_INFO
EXECUTE_FAILED