Skip to Content

Calling procedure with output parameter from XSJS

We are calling a procedure in our XSJS which has an output parameter.

In XSJS we want to read the output parameter.

My code looks like below

var query = "{call\"test"\"test::DELTA_LOAD\"(1,?)}";

var conn = $.db.getConnection();

var pcall = conn.prepareCall(query);


//reading the output parameter in the variable status

var status = pcall['e_status'];

Based on status variable i need to send the email with success or failure

Is there any way to get the return parameter from the stored procedure into a variable?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 20, 2018 at 07:29 AM

    You should not use the old legacy db interface $.db anymore. Use the $.hdb interface. With that you can use the loadProcedure function to load a procedure. That function returns a JS function which executes your stored procedure. Advantage of that is, that the JS function has a clear interface corresponding to the stored procedure interface. You you get also the result back. Check the example in the documentation here ($.hdb, class Connection, function loadProcedure).

    Another option is to use the procedure function of the XS DB utilities (check the example here).


    Add comment
    10|10000 characters needed characters exceeded