cancel
Showing results for 
Search instead for 
Did you mean: 

sample XSJS program

Former Member
0 Kudos

Hi All,

     Can Any one tell me how to retrieve the multiple records based on given inputs from hana data base table through XSJS application.

Thanks & Regards,

Hemanth Reddy M.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Here is a quick and dirty example where TCURR table of saphea is being read and displayed in a html table.

Hope this gives you a basic idea of mutirecord resultset. You may enhance it further.

to test you can point some different table which has less number of records because I have not given any where clause.

========================

$.response.contentType = "text/html";

var output = "Hello User, " + $.session.getUsername() + " <br><br>";

var conn = $.db.getConnection();

var pstmt = conn.prepareStatement( "SELECT * FROM saphea.TCURR" );

var rs = pstmt.executeQuery();

var meta = rs.getMetaData();

var i=1;

var colCount = meta.getColumnCount();

var colName = 1;

output = output + "<table border=\"1\"><tr>";


// displays Column Name of TCURR table

for (i=1; i<= colCount ; i++){

  

    output = output + "<td>" + meta.getColumnName(i) + "</td>";

   

}

output = output + "</tr>";


// displays Data of TCURR table

while(rs.next())

{

  output=output+"<tr>";

  for ( i = 1; i<= colCount ; i++){

  

  output = output + "<td>" + rs.getString(i) + "</td>";

  }

  output=output+"</tr>";

}

output = output + "</table>";

rs.close();

pstmt.close();

conn.close();

$.response.setBody(output);

Sample Output:

Answers (1)

Answers (1)

Former Member
0 Kudos

HI All ,

      Can any please help me in this.

Thanks & Regards,

Hemanth Reddy M.

Former Member
0 Kudos

Attaching xsjs file.