Query
Simplified query functionality, accepts SQL script and query parameters and returns the result-set as a JSON object.
- Module:
db/v4/query
- Alias:
db/query
- Definition: https://github.com/eclipse/dirigible/issues/48
- Source: /db/v4/query.js
- Facade: DatabaseFacade
- Status:
stable
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"], "local", "SystemDB");
response.println(JSON.stringify(resultset));
response.flush();
response.close();
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'}]