Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Retrieving data from table with XSJS

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 (! {

    $.response.setBody( "Failed to retrieve data" );

    $.response.status = $.net.http.INTERNAL_SERVER_ERROR;


else {

    output = rs.getString(1);






But I get the following error:

InternalError: dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at ptime/query/checker/ (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".

Former Member
Not what you were looking for? View more on this topic or Ask a question