Hi folks,
Just a follow up that I found a bit more documentation on exception handling underneath the trigger section of the HANA SQL guide for SP5 (not the SQLScript guide as one might expect). Check out page 99 of the guide.
Another useful feature of this functionality is RESIGNAL. Example use case:
1) You want to stop execution of a stored procedure under certain circumstances but don't need to throw an error (i.e. you need something like 'return' in Java).
2) In order to implement this, you signal a custom condition that you defined call MYCOND, and you also defined an EXIT_HANDLER that handles exceptions.
3) You want to make sure that other SQL exceptions still get thrown (i.e. you don't want them 'caught up' in your generic exit handler.
In this case, you can do something like this:
DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
IF (::SQL_ERROR_CODE != 10001) THEN
RESIGNAL;
ELSE
-- do whatever else you might want to do once your custom exception is caught. Kind of like 'finally' following a try/catch block
END;
-- in your proc, when you want to stop execution because, for example, you have your answer, signal your exception:
SIGNAL MYCOND SET MESSAGE_TEXT = 'If this exception is handled, this message won't make it to the client';