WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:sqlPSBatch
Description:The active:sqlPSBatch service sends a set (batch) of separate prepared SQL statements to a database as a single group with parameterized fields.
Id:mod-db:sqlPSBatch
Category:accessor
Identifier Syntax

sqlPSBatch is an accessor using Active URI syntax with the following base identifiers:

Base
active:sqlPSBatch

and the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
operand
Mandatory
Representation (java.lang.Object)Document with SQL statement and one or more sets of statement parameters
configuration
Optional
Representation (java.lang.Object)Connection pool configuration
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The response representation of this accessor for SOURCE requests is unknown.

This accessor throws no documented exceptions.

Import Requirements

To use sqlPSBatch accessor you must import the module urn:org:netkernel:mod:db:

<import>
  <uri>urn:org:netkernel:mod:db</uri>
</import>

When a request with the SOURCE verb is issued to active:sqlPSBatch the set of SQL queries specified in the required operand argument is used with the database connection pool specified in the optional configuration argument. (If the configuration argument is not supplied then the service issues a request for the resource res:/etc/ConfigRDBMS.xml in the current space.) The response representation is returned as an HDS structure in which each updated-rows node contains the number of rows changed by each of the multiple SQL statements.

For example, the following HDS will update two users email addresses:

<batch>
  <sql>UPDATE users SET email=? WHERE fullname=?;</sql>
  <statements>
    <statement>
      <param>tab@1060research.com</param>
      <param>Tony Butterfield</param>
    </statement>
    <statement>
      <param>pjr@1060research.com</param>
      <param>Peter Rodgers</param>
    </statement>
  </statements>
</batch>

Will return an HDS:

<hds>
  <updated-rows>1</updated-rows>
  <updated-rows>1</updated-rows>
</hds>

The argument operand is requested by the service as a HDS.

The param values can either be supplied in as the object type expected by JDBC or, if the database driver supports parameter meta data, they can be supplied as any object type and automatic transreption will occur.

Example

The following code implements the example illustrated above.

request = context.createRequest("active:sqlBatch");
b1 = new HDSBuilder();
b1.pushNode("batch");
b1.addNode("sql","UPDATE users SET email=? WHERE fullname=?;");
b1.pushNode("statements");
b1.pushNode("statement");
b1.addNode("param","tab@1060research.com");
b1.addNode("param","Tony Butterfield");
b1.popNode();
b1.pushNode("statement");
b1.addNode("param","pjr@1060research.com");
b1.addNode("param","Peter Rodgers");
b1.popNode();
request.addArgumentByValue("operand", b1.getRoot())
hds = context.issueRequest(request);