Database Query

Simplified query functionality, accepts SQL script and query parameters and returns the result-set as a JSON object.

Version 4.x

Basic Usage

var query = require("db/v4/query");
var response = require("http/v4/response");

var sql = "SELECT * FROM DIRIGIBLE_EXTENSIONS WHERE EXTENSION_EXTENSIONPOINT_NAME = ?";
var resultset = query.execute(sql, ["ide-editor"]);

response.println(JSON.stringify(resultset));

response.flush();
response.close();

Definition

Functions


Function Description Returns
execute(sql, parameters?, databaseType?, datasourceName?) Executes a SQL query against the selected databaseType and datasourceName with the provided parameters result-set as JSON object

parameters array supports primitives e.g. [1, ‘John’, 34.56] or objects in format {‘type’:’[DATA_TYPE]’, ‘value’:[VALUE]} e.g. [1, {‘type’:’CHAR’, ‘value’:’ISBN19202323322’}]

Compatibility

Rhino Nashorn V8 Graal

Version 3.x

Basic Usage

var query = require("db/v3/query");
var response = require("http/v3/response");

var sql = "SELECT * FROM DIRIGIBLE_EXTENSIONS WHERE EXTENSION_EXTENSIONPOINT_NAME = ?";
var resultset = query.execute(sql, ["ide-editor"]);

response.println(JSON.stringify(resultset));

response.flush();
response.close();

Definition

Functions


Function Description Returns
execute(sql, parameters?, databaseType?, datasourceName?) Executes a SQL query against the selected databaseType and datasourceName with the provided parameters result-set as JSON object

parameters array supports primitives e.g. [1, ‘John’, 34.56] or objects in format {‘type’:’[DATA_TYPE]’, ‘value’:[VALUE]} e.g. [1, {‘type’:’CHAR’, ‘value’:’ISBN19202323322’}]

Compatibility

Rhino Nashorn V8

Edit