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

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

Base
active:sqlPSUpdate

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
param
0 ... infinity
Representation (java.lang.Object)Prepared Statement Parameter (order dependent)
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 sqlPSUpdate 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.)

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.

Parameter Substitution

Parameters in the prepared statement SQL are denoted by a question mark ?. For example

UPDATE users SET haircolor = ? WHERE age < ? AND eyecolor=?;

Parameters are order dependent. Each delimited parameter must be provided as a param argument on the request. The java class type of the param argument is determined during the preparation of the statement with the database. The param argument will be SOURCEd with a Java class determined by the JDBC PreparedStatement using the ParameterMetadata. It is essential that the supplied parameter either be of the correct type, or is transreptable to the correct type.

Response

By default, the response representation is returned as an HDS structure in which a resultset node contains a row node for each row returned by the query.

The response representation takes the same form as documented for active:sqlUpdate

Example

The following code implements an example prepared statement update with one parameter.

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