简体   繁体   English

SAP HANA:如何在嵌套过程引发的过程中捕获SQL异常?

[英]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: 我有一个在特定情况下会引发异常的SQL过程:

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: 在另一个SQL过程中调用此SQL过程,在该过程中我尝试捕获此异常,如下所示:

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. DECLARE EXIT HANDLER FOR SQLEXCEPTION断点不起作用。

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. 我认为,您可以从嵌套过程中删除异常处理程序,也可以从中抛出异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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