Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Complete Table Data not getting downloaded into Excel

$
0
0

Hello,

 

I am trying to download the complete table data using .xsjs(As explained in tutorial). Table contains around 41K records.

I have simply specified the query as "Select * from <TableName>". However when i try to execute the script it fails to download the data from the table.

 

I also observed that, if i specify "Select top 35000 from <TableName>" it works absolutely fine.

But if i specify "Select top (>35000) from <TableName>" it fails to download.

 

Please help me in resolving this issue.

 

Please find the Script details mentioned below.

function DownloadExcel(type){

  var body = '';

  var query = "select * from \"<Schemaname>\".\"<Table_Name>"+type+"\"";

  var filename = "attachement; filename=ResultSet_"+type+".xls";

  try {

 

  var conn  = $.db.getConnection();

  var pstmt = conn.prepareStatement(query);

  var rs    = pstmt.executeQuery();

  body =  "<Here I am filling the column names of the table>"

  while (rs.next()){   

  body += rs.getString(1) + "\t" + rs.getString(2) + "\t"

       + rs.getString(3) + "\t" + rs.getString(4) + "\t"

       + rs.getString(5) + "\t" + rs.getString(6) + "\t"

       + rs.getString(7) + "\t" + rs.getString(8) + "\t"

       + rs.getString(9) + "\t" + rs.getString(10) + "\t"

       + rs.getString(11) + "\t" + rs.getString(12) + "\t"

       + rs.getString(13) + "\t" + rs.getString(14) + "\t"

       + rs.getString(15) + "\t" + rs.getString(16) + "\t"

       + rs.getString(17) + "\t" + rs.getString(18) + "\t"

       + rs.getString(19) + "\n";

    } 

  }catch (e){       

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

  $.response.setBody(e.message);

  return;

  }

  $.response.setBody(body);

  $.response.contentType = 'application/vnd.ms-excel; charset=utf-16le';

  $.response.headers.set('Content-Disposition', filename);

  $.response.headers.set('access-control-allow-origin', '*');

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

}

 

var aCmd = $.request.parameters.get('cmd');

switch (aCmd) {

case 'C_C':

  DownloadExcel(aCmd);

  break;

case 'C_V':

  DownloadExcel(aCmd);

  break;

case 'V_V':

  DownloadExcel(aCmd);

  break;

case 'V_C':

  DownloadExcel(aCmd);

  break;

default:

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

     $.response.setBody('Invalid Command: '+aCmd);

}

 

Regards

Raghavendra.D.S


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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