cancel
Showing results for 
Search instead for 
Did you mean: 

conn.prepareCall is not a function - XSJS Error

former_member224398
Participant
0 Kudos

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);
	
}

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member224398
Participant

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

0 Kudos

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/584de7593b8748d8a8c6586613...

This will resolve your issue.

Good Luck!!!

former_member224398
Participant
0 Kudos

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.