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:sqlPSBooleanQuery
Description:The active:sqlPSBooleanQuery service retrieves information from a relational database (RDBMS) using SQL prepared statement and returns a Boolean result.
Id:mod-db:sqlPSBooleanQuery
Category:accessor
Identifier Syntax

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

Base
active:sqlPSBooleanQuery

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

ArgumentRulesTypingDescription
operand
Mandatory
Representation (java.lang.Object)SQL query 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 sqlPSBooleanQuery 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:sqlPSBooleanQuery the SQL query specified in the required operand argument is prepared for 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 Boolean.

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 and used to create the prepared statement.

Parameter Substitution

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

SELECT * FROM users 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

The value returned is true if at least one row is returned from the query and is false if no rows are returned from the query.

The boolean value of the response representation is determined using the same ResultSet criterion as for active:sqlBooleanQuery

Example

The following code implements the example query illustrated above.

request = context.createRequest("active:sqlPSBooleanQuery");
request.addArgumentByValue("operand", "SELECT * FROM users WHERE firstname=?;")
request.addArgumentByValue("param", "Murray");
if (context.issueRequest(request))
  {
  ...
  }