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 .

Description:The active:sqlBatch service sends a set (batch) of separate SQL statements to a database as a single group.
Identifier Syntax

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


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

Representation (java.lang.Object)Document with multiple SQL statements to be executed
Representation (java.lang.Object)Connection pool configuration
Request Verbs

The following verb is supported:


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

This accessor throws no documented exceptions.

Import Requirements

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


When a request with the SOURCE verb is issued to active:sqlBatch 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 create a new database for an application:

  <sql>DROP TABLE users IF EXISTS;</sql>
  <sql> CREATE CACHED TABLE users ( user_id VARCHAR( 100) NOT NULL, fullname VARCHAR( 100), password VARCHAR( 100), email VARCHAR( 200) );</sql>
  <sql>CREATE PRIMARY KEY ON users(user_id);</sql>
  <sql>INSERT INTO users (user_id, fullname, email, password) VALUES ( 'jim', 'James Tobin', 'jim@myco.com', 'meto');</sql>
  <sql>INSERT INTO users (user_id, fullname, email, password) VALUES ( 'chuck', 'Charles Burst', 'cb@myco.com', 'meto');</sql>

Will return an HDS:


The argument operand is requested by the service as a HDS which allows the supplied representation type to be any of the forms that can be transrepted to a DeterminateString.


The following code implements the example illustrated above.

request = context.createRequest("active:sqlBatch");
builder = new HDSBuilder();
builder.addNode("sql","DROP TABLE users IF EXISTS;");
builder.addNode("sql","CREATE CACHED TABLE users (user_id VARCHAR(100) NOT NULL, fullname VARCHAR(100), password VARCHAR(100), email VARCHAR(200));");
builder.addNode("sql","CREATE PRIMARY KEY ON users(user_id);");
builder.addNode("sql","INSERT INTO (user_id, fullname, email, password) VALUES ('jim',   'James Tobin',   'jim@myco.com', 'meto');");
builder.addNode("sql","INSERT INTO (user_id, fullname, email, password) VALUES ('chuck', 'Charles Burst', 'cb@myco.com',  'meto');");
request.addArgumentByValue("operand", builder.getRoot())
hds = context.issueRequest(request);

Another alternative implementation uses an externally define resource:

request = context.createRequest("active:sqlBatch");
hds = context.issueRequest(request);