javascriptsapui5procedurehanaxsjs

Signal a procedure and give the control back to procedure in HANA


I am calling a procedure from my xsjs file as follows

  try{
    var query = oConn.loadProcedure("hello","helloWorld.db::sampleException");

    query();
    $.response.setBody('OK');
    $.response.status = $.net.http.OK;
}

    catch(e){
        var code= getStatusCode(e.message);
        if(code&& code === 301){
            $.response.setBody('unique Constraint Voilated');
        }
        if(code && code ===258)
        {
            $.response.setBody('You dont have the Permission to run the command'+code);
            }
        if(code && code ===10001)
            {
            $.response.setBody('Boss you got the error');
            }
        if(code && code ===10002)
        {
        $.response.setBody('Boss you got the error2');
        }

the procedure is as follows:

    PROCEDURE "hello"."helloWorld.db::sampleException" ()
     AS
BEGIN

DECLARE ExceptionExample CONDITION FOR SQL_ERROR_CODE 10001;
DECLARE ExceptionExample1 CONDITION FOR SQL_ERROR_CODE 10002;


select * from "hello"."REGION";
SIGNAL ExceptionExample SET MESSAGE_TEXT='TAN TAN TANANANANAN';


--SIGNAL 
select * from "hello"."REGION";
SIGNAL ExceptionExample1 SET MESSAGE_TEXT='TANY TAN TANANANANAN';

END;

I want to signal both the exceptions when the XSJS is called. Any way to do that?

Output (should be): Boss you got the error. Boss you got the error2.

Any help would be beneficial.

Thanks.


Solution

  • Nope, that's not possible. SAP HANA procedures allow one single exception to be signalled. Exceptions that happened 'deeper down the stack' are not stacked and effectively hidden.