on 10-25-2016 4:50 PM
Hi Experts,
I have written following lines of code to display all the schema name returned by the xsjs script on the content body. But it's not showing any schema name on the content body of the webpage. Could you please guide me if I am missing something?
var connection=$.db.getConnection();
var output="";
output=connection.prepareStatement("SELECT SCHEMA_NAME FROM SYS.SCHEMAS WHERE HAS_PRIVILEGES = \'TRUE\' AND SCHEMA_OWNER NOT IN (\'_SYS_REPO\',\'SYSTEM\',\'_SYS_STATISTICS\')").execute();
connection.commit();
$.response.contentType = "text/html";
$.response.setBody(output);
Regards,
Shawon
Hello Shawon,
there are different issues in your coding:
Following returns the result of the same query using the new HDB interface ($.hdb). The result is returned as json. No preparation is necessary, because the result procuced by the new HDB interface is a json object.
let connection = $.hdb.getConnection();
let result = connection.executeQuery("SELECT SCHEMA_NAME FROM SYS.SCHEMAS WHERE HAS_PRIVILEGES = \'TRUE\' AND SCHEMA_OWNER NOT IN (\'_SYS_REPO\',\'SYSTEM\',\'_SYS_STATISTICS\')");
$.response.contentType = "application/json; charset=utf-8";
$.response.setBody(JSON.stringify(result));
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Florian,
Thank you so much for your kind and timely response. Your code works perfectly.
But you have used different syntax like "letconnection=$.hdb.getConnection();" . So I am just wondering if you have any document which I can follow to get acquainted with the syntax that you used and get some knowledge on this. It will be a great help if you can share some document or link to follow.
I sincerely appreciate your help.
Regards,
Shawon
The reference for the new $.hdb interface can be found here: $.hdb
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.