Skip to main content

snippets_js

Integration

New integration from credential
const connection = yepcode.integration.sapHana('credential-slug');
New integration from plain authentication data
const hana = require('@sap/hana-client');

const connection = hana.createConnection();
connection.connect({
serverNode: 'your-host-and-port',
uid: 'your-user',
pwd: 'your-password',
sslValidateCertificate: 'false'
});

Disconnect

Disconnect (callback)
connection.disconnect(function(err) {
if (err) throw err;
console.log('Disconnected');
});

DDL Statement

DDL Statement
connection.exec('CREATE TABLE Test (ID INTEGER PRIMARY KEY, msg VARCHAR(128))',
function (err, result) {
if (err) throw err;
console.log('Table Test created!', result);
});

DML Statement

DML Statement
connection.exec("INSERT INTO Test VALUES(1, 'Hello')", function (err, affectedRows) {
if (err) throw err;
console.log('Number of affected rows:', affectedRows);
});

Query

Query
connection.exec("SELECT * FROM Test WHERE ID < 5", function (err, rows) {
if (err) throw err;
console.log('Rows:', rows);
});

Query Parametrized

Query Parametrized
connection.exec("SELECT * FROM Test WHERE ID BETWEEN ? AND ?", [5, 8],
function (err, rows) {
if (err) throw err;
console.log('Rows:', rows);
});