Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Retrieving data from table with XSJS

$
0
0

I'm trying to execute a SQL query with XSJS.

 

I followed all steps here: SAP HANA Cloud Platform

and was able to successfully execute the example provided in "7. Create the JavaScript File". I even got a result:

Hello, P123456789.

This is the response from my SQL. The current user is: P123456789

 

But now I want to read some data from a table. I changed the code to this:

 

$.response.contentType = "text/html";
var output;
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement('SELECT * FROM "NEO_123456789ABCDEF"."MYTABLE1"');
var rs = pstmt.executeQuery();
if (!rs.next()) {    $.response.setBody( "Failed to retrieve data" );    $.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else {    output = rs.getString(1);
}
rs.close();
pstmt.close();
conn.close();
$.response.setBody(output);

But I get the following error:

InternalError: dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at ptime/query/checker/query_check.cc:2422 (line 4 position 0 in /p123456789trial/instance1/test/myxsproject/script1.xsjs)

Of course, I also followed the steps "6. Create the Application Descriptors and Role" and "8. Grant the Role to the User".


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>