I am new to SAP HANA and trying to expose the .xsjs file data through the webbrowser with the following url:
hostname:80<instance#>/workspace/session/a00/data/services/retrieveData.xsjs
However, I am getting the following error when I try to access it:
This link seems to be broken We could not find the resource you're trying to access. It might be misspelled or currently unavailable
These are the files which I have created in the project explorer:
MYSCHEMA.hdbschema
schema_name="MYSCHEMA"
trendsData.hdbtable
table.schemaName = "MYSCHEMA";
table.tableType = COLUMNSTORE;
table.description = "NewDataSet Order trendsData";
table.columns = [
{name= "C"; sqlType = NVARCHAR; nullable = true; length=10; },
{name= "D"; sqlType = VARCHAR; nullable = true; length=5; },
{name= "DU"; sqlType = NVARCHAR; nullable = true; length=20; },
{name= "SA"; sqlType = DECIMAL; nullable = true; length=30; },
{name= "I"; sqlType = DECIMAL; nullable = true; length=30; },
{name= "G"; sqlType = DECIMAL; nullable = true; length=30; },
{name= "G"; sqlType = DECIMAL; nullable = true; length=20; },
{name= "STR"; sqlType = DECIMAL; nullable = true; length=30; }
];
table.primaryKey.pkcolumns = ["INVENTORY"];
orderId.hdbsequence
schema="MYSCHEMA";
start_with=2000000;
cycles=false;
depends_on_table="workspace.session.a00.data::trendData";
retrieveData.xsjs
$.response.contentType="text/html";
var output = "Helloworld";
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement("select * from trendData");
var rs = pstmt.executeQuery();
if (!rs.next())
{
$.response.setBody( "Failed to retrieve data");
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else
{
output=output + "This is the respose from my SQL: "
+ rs.getString(1);
}
rs.close();
pstmt.close();
conn.close();
$.response.setBody(output);
All the above files were succesfully committed and activated with out any error. Still, the error occurs in the webrowser.
Your select statement does not specify a schema. In addition the table's catalog name is usually "package name::table name". In addition your table definition has two columns with the same name and an invalid primary key specification.
Thus I would expect that the select fails. As a first step I would suggest to try
Once you get this running you know that the web access works. My next step would be to wrap everything into some try / catch like so
This would then allow to pinpoint where exactly your code fails.