
@sap/hana-client vs. @sap/hdbext
In the @Sisn/hdbext example, you get all the expanded feature coverage of the @Sisn/hana-client but also have the simpler connection handling and compatibility with hdb module because of the historic usage of both modules. It must do the name mapping for the connection settings internally.
var dbStream = require('@sap/hana-client/extension/Stream');
dbStream.createProcStatement(client, 'CALL PROC_DUMMY (?, ?, ?, ?, ?)', function (err, stmt) {
if (err) {
return console.error('createProcStatement error:', err);
}
stmt.exec({ A: 3, B: 4 }, function (err, params, dummyRows, tablesRows) {
if (err) {
return console.error('exec error:', err);
}
stmt.drop(function (err) {
if (err) {
return console.error('drop error:', err);
}
console.log('C:', params.C);
console.log('Dummy rows:', dummyRows);
console.log('Tables rows:', tablesRows);
});
});
});/**
* hdbext procedure example with Callbacks
* @param {string} [schema] Database Stored Procedure Schema
* @param {string} [dbProcedure] Database Stored Procedure Name
* @param {object} [inputParams] Database Stored Procedure Input Parameters
* @param {Callback} [callback] Callback Function to receive results
*/
export function example2(schema, dbProcedure, inputParams, callback) {
xsenv.loadEnv()
let hanaOptions = xsenv.getServices({
hana: {
label: "hana"
}
})
hdbext.createConnection(hanaOptions.hana, (err, client) => {
if (err) {
callback(err)
} else {
hdbext.loadProcedure(client, schema, dbProcedure, (err, sp) => {
if (err) {
callback(err)
} else {
sp(inputParams, (err, parameters, tableRows) => {
client.disconnect()
callback(null, parameters)
})
}
})
}
return null
})
}import dbClass from "sap-hdbext-promisfied"
export async function example1(dbQuery) {
try {
let db = new dbClass(await dbClass.createConnectionFromEnv())
return await db.execSQL(dbQuery)
} catch (error) {
throw error
}
}
@sap/hana-client vs. sap-hdbext-promisfied

@sap/hdbext vs. sap-hdbext-promisfied Stored Procedures
import dbClass from "sap-hdb-promisfied"
export async function example1(dbQuery) {
try {
let db = new dbClass(await dbClass.createConnectionFromEnv())
let result = await db.execSQL(dbQuery)
db.destroyClient()
return result
} catch (error) {
throw error
}
}
sap-hdbext-promisfied vs. sap-hdb-promisfied
import express from 'express'
import hdbext from "@sap/hdbext"
import * as xsenv from "@sap/xsenv"
this.app = express()
/**
* Start Express Server
*/
async start() {
let app = this.app
xsenv.loadEnv()
let hanaOptions = xsenv.getServices({
hana: {
tag: "hana"
}
})
hanaOptions.hana.pooling = true
app.use(
hdbext.middleware(hanaOptions.hana)
)
this.httpServer = app.listen(this.port)
} app.get("/rest/hdbext",
(/** @type {express.Request} */ req, /** @type {express.Response} */ res) => {
let client = req.db
client.prepare(
`SELECT CURRENT_USER, CURRENT_SCHEMA FROM "DUMMY"`,
(err, statement) => {
if (err) {
return res.type("text/plain").status(500).send("ERROR: " + err.toString())
}
statement.exec([],
(err, results) => {
if (err) {
return res.type("text/plain").status(500).send("ERROR: " + err.toString())
} else {
return res.type("application/json").status(200).send(results)
}
})
return null
})
}) app.get("/rest/hdbextAsync",
async (/** @type {express.Request} */ req, /** @type {express.Response} */ res) => {
try {
let db = new dbClass(req.db)
const statement = await db.preparePromisified(`SELECT SESSION_USER, CURRENT_SCHEMA
FROM "DUMMY"`)
const results = await db.statementExecPromisified(statement, [])
return res.type("application/json").status(200).send(results)
} catch (e) {
return res.type("text/plain").status(500).send(`ERROR: ${e.toString()}`)
}
}) app.get("/rest/procedures",
async (/** @type {express.Request} */ req, /** @type {express.Response} */ res) => {
try {
let db = new dbClass(req.db)
let sp = await db.loadProcedurePromisified(hdbext, 'SYS', 'IS_VALID_PASSWORD')
res.type("application/json").status(200).send(await db.callProcedurePromisified(sp, { PASSWORD: "TEST" }))
} catch (error) {
res.type("text/plain").status(500).send(`ERROR: ${error.toString()}`)
return
}
}) app.get("/rest/procedures2/:password",
async (/** @type {express.Request} */ req, /** @type {express.Response} */ res) => {
try {
let password = req.params?.password
let inputParams = {}
if (typeof password === "undefined" || password === null) {
inputParams = {}
} else {
inputParams = {
PASSWORD: password
}
}
let db = new dbClass(req.db)
let sp = await db.loadProcedurePromisified(hdbext, 'SYS', 'IS_VALID_PASSWORD')
res.type("application/json").status(200).send(await db.callProcedurePromisified(sp, inputParams))
} catch (error) {
res.type("text/plain").status(500).send(`ERROR: ${error.toString()}`)
return
}
}) app.get("/rest/queriesParallel/",
async (/** @type {express.Request} */ req, /** @type {express.Response} */ res) => {
try {
let db = new dbClass(req.db)
let result = {}
let [outputOne, outputTwo] = await Promise.all([queryOne(), queryTwo()])
result.outputOne = outputOne
result.outputTwo = outputTwo
return res.type("application/json").status(200).send(result)
async function queryOne() {
const statement = await db.preparePromisified(`SELECT SESSION_USER, CURRENT_SCHEMA FROM "DUMMY"`)
return await db.statementExecPromisified(statement, [])
}
async function queryTwo() {
let sp = await db.loadProcedurePromisified(hdbext, 'SYS', 'IS_VALID_PASSWORD')
return await db.callProcedurePromisified(sp, { PASSWORD: "TEST" })
}
} catch (e) {
return res.type("text/plain").status(500).send(`ERROR: ${e.toString()}`)
}
})
Parallel Query Performance Measurement
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 36 | |
| 28 | |
| 27 | |
| 26 | |
| 26 | |
| 26 | |
| 24 | |
| 23 | |
| 22 | |
| 22 |