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:sqlUpdate
Description:The active:sqlUpdate service is used to execute SQL INSERT, UPDATE and DELETE statements which will add, change or delete data in a database.
Id:mod-db:sqlUpdate
Category:accessor
Identifier Syntax

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

Base
active:sqlUpdate

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

ArgumentRulesTypingDescription
operand
Mandatory
Representation (java.lang.Object)SQL update statement to be executed
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 sqlUpdate 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:sqlUpdate the SQL query 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.) By default, the response representation is returned as an HDS structure in which a updated-rows node contains the number of rows changed by the query.

For example, for the table "Users":

FIRSTNAMELASTNAMEAGE
MichaelSmith42
SusanJamison38

the query

DELETE FROM users WHERE age='42';

will return

<root>
  <updated-rows>1</updated-rows>
</root>

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

Example

The following code implements the example query illustrated above.

request = context.createRequest("active:sqlUpdate");
request.addArgumentByValue("operand", "DELETE FROM users WHERE age='42';")
hds = context.issueRequest(request);