cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Stored Procedure from XSJS in XS Classic

0 Kudos

Hi,

I am trying to call the stored proc from XSJS in XS Classic. This is my code:

var conn;
try {
	conn = $.hdb.getConnection();
	
	var fn = conn.loadProcedure("GUNAWF01", "ACCESS_TEST.FD.STORED_PROCEDURES::PR_050_HTS_SQL_TRAINd");
	//var fnResult = fn(searchStrategy);
	conn.commit();
	conn.close();
	$.response.setBody("Training finished.");
	$.response.status = $.net.http.OK;
	
} catch (err) {
    $.response.contentType = "text/plain";
    $.response.setBody("Error while executing query: [" + err.message + "]");
    $.response.returnCode = 200;
}

It looks like the stored procedure is never called. I got the message "Training Finished", but I don't see any output from the stored procedure. Not sure what is missing.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate

Well in the code above you have the call to the stored procedure commented out. Is that really what's in your service? If so that perfectly explains why the procedure isn't called. The loadProcedure just loads the metadata of the procedure and creates a JavaScript proxy function for it. You still have to call that function to execute the procedure.

0 Kudos

Thanks Thomas for your help.

I figured it out how to call the procedure.

Regards

Ferry

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

As I said above you have the actual call commented out (the // before that line).