简体   繁体   中英

SAP HANA: how to catch SQL exception in procedure thrown by nested procedure?

I have a SQL procedure which throws an exception in particular cases:

SIGNAL EMPTY_REQ_ATTR SET message_text = 'my mega error message';

This procedure has an exit handler:

DECLARE EMPTY_REQ_ATTR CONDITION;
DECLARE EXIT HANDLER FOR EMPTY_REQ_ATTR RESIGNAL EMPTY_REQ_ATTR;

This SQL procedure is called in another SQL procedure where I try to catch this exception like this:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
    errors = SELECT 400 AS http_code, ::SQL_ERROR_MESSAGE AS message FROM dummy;
END;

But in debug I see that exit handler only works in nested procedure. Breakpoint at DECLARE EXIT HANDLER FOR SQLEXCEPTION not working.

As I understand you have already caught this exception in your nested procedure and exception did not get thrown again. I think, you can remove exception handler from nested procedure or throw exception from it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM