Skip to Content
0

HANA WEB Service Fuzzy search

Feb 09 at 06:32 PM

41

avatar image
Former Member

I am creating a Fuzzy search to look up Old_Cust name in table and retrieve and display new customer name from the same table through web service in hana.

I am getting 500-internal server error with this below code :

var output = { data:[] };
var OLD_CUSTNAME = $.request.parameters.get('OLD_CUSTNAME');
var query = 'SELECT DISTINCT CUSTNAME, OLD_CUSTNAME FROM Customer_table WHERE (CUSTNAME IN (% ' + OLD_CUSTNAME + ' %))';

var conn = $.db.getConnection();
var pstmt = conn.prepareStatement( query );
var rs = pstmt.executeQuery();
if (!rs.next()) {
$.response.setBody( "Failed to retrieve data" );
$.response.contentType = 'application/json';
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else{
output.data.push({"CUSTNAME" : rs.getString(1),
"OLD_CUSTNAME" : rs.getString(2)});
while(rs.next())
{
output.data.push({"CUSTNAME" : rs.getString(1),
"OLD_CUSTNAME" : rs.getString(2)
});

}
// root.data.push(output);
$.response.status = $.net.http.OK;
$.response.contentType = 'application/json';
$.response.setBody( JSON.stringify(output) );
}
rs.close();
pstmt.close();
conn.close();

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers