Skip to Content
0

conn.prepareCall is not a function - XSJS Error

Jul 03, 2017 at 12:36 PM

124

avatar image
Former Member

Hi,

I'm trying to trigger a procedure from XSJS file but I'm always getting the error as "conn.prepareCall is not a function". Below is my simple code for XSJS file.

It seems it is having a issue with the call statement. if yes what would be the correct Call statement ?

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

//var param_date = $.request.parameters.get('pdate');
//var param_version = $.request.parameters.get('pversion');
//var param_dataset = $.request.parameters.get('pdataset');

var call = "{CALL \"FIN_FPA\".\"PR_SNAPSHOT_LOAD_DATA\()}";
//"call \"MyPackage.procedures::addUserC50\"(?, ?, ?)";
try{
	
	var conn = $.hdb.getConnection();
	var pc = conn.prepareCall(call);
	
	pc.execute();
	pc.close();
	
	conn.comit();
	conn.close();
	
}catch(error){
	
	$.response.setBody("failed to trigger the procedure. <br> Error Message : " + error);
	$.response.status($.net.http.INTERNAL_SERVER_ERROR);
	
}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Jul 05, 2017 at 08:20 AM
0

Hi Anurag,

Try using the "sap.hana.xs.libs.dbutils" library as mentioned in the below documentation link:

https://help.sap.com/viewer/b3d0daf2a98e49ada00bf31b7ca7a42e/2.0.00/en-US/584de7593b8748d8a8c6586613c2439e.html

This will resolve your issue.

Good Luck!!!

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sumit,

Thanks for the input.Good to know the other way around to do this as you have suggested.

I have found the solution of the issue. I was getting connection properties as var conn =$.hdb.getConnection();

Hence in the hdb connection class we don't have method called prepareCall() so that was throwing error.

with HDB connection we need to used loadProcedure() to call a procedure.

0
avatar image
Former Member Jul 05, 2017 at 08:46 AM
0

Hi Guys,

I have resolved the issue and got before closing the question i want to share the solution.

I was getting connection properties as var conn =$.hdb.getConnection();

Hence in the hdb connection class we don't have method called prepareCall() so that was throwing error. So if you want to use prepareCall we need to get the connection details as var conn =$.db.getConnection();

With HDB connection we need to use the loadProcedure() to call a procedure also we can provide the arguments/parameters to the procedure.

Thanks,

Anurag

Share
10 |10000 characters needed characters left characters exceeded