-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_3.xsjs
69 lines (58 loc) · 1.8 KB
/
example_3.xsjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// import DataTable Server-Side Processing library
var dataTable = $.import("your.package.name", "DataTable");
// or
// var dataTable = $.import("/your/package/name/DataTable.xsjslib");
// connect to Hana
var conn = $.db.getConnection();
app.setSchema(conn, 'MY_SCHEMA');
var output = {};
try {
var tableName = 'MY_TABLE';
// start library with parameters received by HTTP Request $.request.parameters
// it can be ommited if their values aren't important outside the library
var inputParams = dataTable.getRequestParameters();
/**
* inputParams : {
* draw: @integer,
*
* start: @integer,
*
* length: @integer,
*
* search: {
* value: @string,
* regex: @boolean
* },
*
* order: [{
* column: @integer,
* dir: @string
* }, ...],
*
* columns: [{
* data: @string,
* name: @string,
* searchable: @boolean,
* orderable: @boolean,
* search: {
* value: @string,
* regex: @boolean
* }
* }, ...]
*/
// read parameters received for any purpose ..
// however, change their values won't take effect on the processing method below
// execute queries and retrieve output parameters expected by DataTable
output = dataTable.process(conn, tableName);
$.response.status = $.net.http.OK;
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify(output));
} catch(e) {
output = "Exception "+ JSON.stringify(e);
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
$.response.contentType = "plain/text";
$.response.setBody( output );
} finally {
// close connection to Hana
conn.close();
}