Skip to content

Commit ad8ac91

Browse files
authored
Merge pull request #23094 from danielva/master
Updates to Client, alerts, and DBX tutorials
2 parents aa743e2 + a8445ad commit ad8ac91

6 files changed

Lines changed: 76 additions & 22 deletions

File tree

tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ This step demonstrates how to connect to a SAP HANA instance using [HDBSQL](http
157157
### Create user and schema
158158
159159
160-
This step creates a user named `USER1`. `USER1` will be the owner of the tables that will be created in a subsequent steps and will be used to connect to the database.
160+
This step creates two users and a schema. `USER1` will be the owner of the tables that will be created in a subsequent steps and will be used to connect to the database.
161161
162162
On Linux or a Mac, turn off page by page scroll output. Also, consult the `-j` `hdbsql` option. This enables multiple commands to be pasted at one time and does not require each result to be exited by pressing q.
163163
@@ -169,7 +169,7 @@ On Linux or a Mac, turn off page by page scroll output. Also, consult the `-j`
169169
170170
```SQL
171171
CREATE USER USER1 PASSWORD Password1 no force_first_password_change;
172-
CREATE USER USER2 PASSWORD Password2 no force_first_password_change; --Used in the entity framework tutorial
172+
CREATE USER USER2 PASSWORD Password2 no force_first_password_change; --Used in the Node.js connection pool example and the entity framework tutorial.
173173
```
174174
175175
>The end of this tutorial contains SQL statements to delete the user, schema and objects created. This may be helpful if you wish to recreate the sample dataset used in this tutorial.

tutorials/hana-clients-node/hana-clients-node.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ Node.js packages are available using [NPM](https://www.npmjs.com/), which is the
286286
```
287287
288288
### Create a synchronous app that uses a connection pool
289-
290-
291289
Connection pooling can improve performance when making multiple, brief connections to the SAP HANA database. The following sample makes two connections one after another without using a connection pool and then using a connection pool. It demonstrates how the time taken to make a connection with a connection retrieved from a pool is significantly shorter.
292290
293291
1. Open a file named `nodeQueryConnectionPool.js` in an editor.
@@ -324,6 +322,7 @@ Connection pooling can improve performance when making multiple, brief connectio
324322
poolCapacity: 10, //max # of connections in the pool waiting to be used
325323
maxConnectedOrPooled: 20, //max # of connections in the pool + the # of connections in use
326324
pingCheck: false,
325+
allowSwitchUser: true, //requires SAP HANA Client 2.17
327326
maxPooledIdleTime: 3600, //1 hour (in seconds)
328327
}
329328
@@ -332,38 +331,42 @@ Connection pooling can improve performance when making multiple, brief connectio
332331
queryTable(false, "1st Run");
333332
queryTable(false, "2nd Run");
334333
queryTable(true, "1st Run");
335-
//console.log(pool.clear());
336334
queryTable(true, "2nd Run");
335+
queryTable(true, "3rd Run", true); //change user
337336
console.log("Connections in use :" + pool.getInUseCount());
338337
console.log("Connections in the pool :" + pool.getPooledCount());
339338
340339
//Creates two connections either using connection pooling or not
341340
//Displays timing information
342-
function queryTable(usePool, run) {
341+
function queryTable(usePool, run, user2) {
343342
var t0 = performance.now()
344343
var connection = null;
345-
if (!usePool) {
346-
connection = hana.createConnection();
347-
connection.connect(connOptions);
348-
var t1 = performance.now();
349-
}
350-
else {
344+
if (usePool) { //use the connection pool
351345
var t0 = performance.now();
352346
if (pool === null) {
353347
pool = hana.createPool(connOptions, poolProperties); //create a connection pool
354348
}
355-
356-
connection = pool.getConnection(); //get a connection from the pool
349+
if (user2) { //example of changing the user
350+
connection = pool.getConnection('USER2','Password3'); //Requires 2.17 of the SAP HANA Client
351+
}
352+
else {
353+
connection = pool.getConnection(); //get a connection from the pool
354+
}
355+
var t1 = performance.now();
356+
}
357+
else { //don't use the connection pool
358+
connection = hana.createConnection();
359+
connection.connect(connOptions);
357360
var t1 = performance.now();
358361
}
359362
360363
var t2 = performance.now();
361-
var sql = 'select TITLE, FIRSTNAME, NAME from HOTEL.CUSTOMER;';
364+
var sql = 'select CURRENT_USER FROM DUMMY;';
362365
var result = connection.exec(sql);
363366
var t3 = performance.now();
364367
365368
var t4 = performance.now();
366-
//console.log(util.inspect(result, { colors: false }));
369+
console.log(util.inspect(result, { colors: false }));
367370
var t5 = performance.now();
368371
369372
var t6 = performance.now();
@@ -386,9 +389,11 @@ Connection pooling can improve performance when making multiple, brief connectio
386389
node nodeQueryConnectionPool.js
387390
```
388391
392+
Notice below that the time taken to establish a connection is approx 900 ms which but becomes almost instantaneous when the connection pool is used or about 85 ms when a connection from the pool requires changing the user.
393+
389394
![Running nodeQueryConnectionPool.js](node-query-connection-pool.png)
390395
391-
See [Node.js Connection Pooling](https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/e252ff9b2cb44dd9925901e39025ce77.html) for additional details. The example above uses a new API that was added in the 2.13 release and documented in the 2.14 release. This new API provides a more direct way to interact with the connection pool.
396+
See [Node.js Connection Pooling](https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/e252ff9b2cb44dd9925901e39025ce77.html) for additional details. The example above uses a new API that was added in the 2.17 release.
392397
393398
394399
### Create an asynchronous app that uses callbacks
50.5 KB
Loading

tutorials/hana-cloud-alerts/hana-cloud-alerts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ The following instructions will show how to view a triggered SAP HANA database a
219219
220220
221221
### Trigger an alert in SAP HANA Cloud data lake
222+
The following instructions show one example of triggering the [data lake locked user event](https://help.sap.com/viewer/5967a369d4b74f7a9c2b91f5df8e6ab6/Cloud/en-US/11b9ef0ed4dd4e1dae36147fe313b381.html). The alert will be triggered when a user attempts to log in **after** the user account has been locked because an incorrect password has been provided too many times.
222223
223-
The following instructions show one example of triggering the [data lake locked user event](https://help.sap.com/viewer/5967a369d4b74f7a9c2b91f5df8e6ab6/Cloud/en-US/11b9ef0ed4dd4e1dae36147fe313b381.html). The alert will be triggered when a user attempts to log in after the user account has been locked because an incorrect password has been provided too many times.
224+
>This alert is not available in trial accounts.
224225
225226
1. In an SAP HANA database explorer that is connected to a **data lake**, execute the following SQL to create a login policy and a new user.
226227
@@ -246,8 +247,9 @@ The following instructions show one example of triggering the [data lake locked
246247
247248
![Locked user2](data-lake-user-locked.png)
248249
250+
3. Attempt to connect one more time after the account has been locked (4th time) to trigger the alert.
249251
250-
3. Additional details about users can be seen by calling the procedure `sa_get_user_status`. The user can be unlocked using by resetting the login policy.
252+
4. Additional details about users can be seen by calling the procedure `sa_get_user_status`. The user can be unlocked using by resetting the login policy.
251253
252254
```SQL
253255
CALL sa_get_user_status;
@@ -258,8 +260,6 @@ The following instructions show one example of triggering the [data lake locked
258260
259261
The tutorial [Monitor a Standalone Data Lake in SAP HANA Cloud](hana-cloud-hdl-getting-started-4) may also be of interest as it demonstrates the data lake Relational Engine monitoring views.
260262
261-
262-
263263
### Set up email notification when an alert occurs
264264
265265
The SAP Business Technology Platform (BTP) includes a service called the SAP Alert Notification service (ANS) that provides a common way for other services or applications running in the SAP BTP to send out notifications such as an email, a post to a Microsoft Teams or Slack channel, the creation of a ticket in `ServiceNow`, or a webhook to send events to any Internet REST endpoint. The SAP HANA Cloud database and data lake pass on events to the SAP ANS when an alert is triggered.

tutorials/hana-dbx-hcc/hana-dbx-hcc.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,55 @@ This step demonstrates how to execute a SQL query and view query results, messag
114114
115115
>The history is not persisted across browser reloads.
116116
117+
5. Execute the following SQL statements.
118+
119+
```SQL
120+
SELECT HEXTOBIN ('48656C6C6F20776F726C64') BINARY_EXAMPLE FROM DUMMY;
121+
122+
SELECT '{
123+
"name":"John",
124+
"age":30,
125+
"cars": {
126+
"car1":"Ford",
127+
"car2":"BMW",
128+
"car3":"Fiat"
129+
}
130+
}' AS JSON_EXAMPLE
131+
FROM DUMMY;
132+
133+
SELECT '<?xml version="1.0" encoding="UTF-8"?>
134+
<breakfast_menu>
135+
<food>
136+
<name>Strawberry Belgian Waffles</name>
137+
<price>$7.95</price>
138+
<description>
139+
Light Belgian waffles covered with strawberries and whipped cream
140+
</description>
141+
<calories>900</calories>
142+
</food>
143+
<food>
144+
<name>French Toast</name>
145+
<price>$4.50</price>
146+
<description>
147+
Thick slices made from our homemade sourdough bread
148+
</description>
149+
<calories>600</calories>
150+
</food>
151+
<food>
152+
<name>Homestyle Breakfast</name>
153+
<price>$6.95</price>
154+
<description>
155+
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
156+
</description>
157+
<calories>950</calories>
158+
</food>
159+
</breakfast_menu>' XML_EXAMPLE FROM DUMMY
160+
```
161+
162+
Double tapping on a result will open a result viewer.
163+
164+
![SQL results](result-viewer.png)
165+
117166
### A few things to note
118167
The SQL console within SAP HANA Cloud Central appears similar to the one within the SAP HANA database explorer but there are some differences.
119168
@@ -128,7 +177,7 @@ The SQL console within SAP HANA Cloud Central appears similar to the one within
128177
* SQL parsing to detect potential errors
129178
* Code completion of schema objects
130179
* SQL formatting
131-
* SQL viewers for HTML, XML, JSON, binary, and spatial
180+
* SQL viewers for spatial
132181
* Results can be downloaded in a CSV
133182
* Ability to run statements in the background
134183
* Ability to run statements against multiple instances
97.8 KB
Loading

0 commit comments

Comments
 (0)