Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Difference between SIGNAL and RESIGNAL in exception handling

$
0
0

Hi All,

 

Can anybody explain the exact use of RESIGNAL in exception handling.

 

Below is code snippet from SAP HANA Documentation but I'm not able to figure of the specific use.

 

CREATE TABLE MYTAB (I INTEGER PRIMARY KEY);

 

 

 

CREATE PROCEDURE MYPROC

AS

BEGIN

DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001;

DECLARE EXIT HANDLER FOR MYCOND RESIGNAL;

INSERT INTO MYTAB VALUES (1);

SIGNAL MYCOND SET MESSAGE_TEXT = 'my error';

-- will not be reached

END;

 

After executing the below code , I'm getting the error code as below.

 

Could not execute 'CALL MYPROC' in 335 ms 830 µs .

SAP DBTech JDBC: [10001]: user-defined error:  [10001] "XYZ"."MYPROC": line 5 col 33 (at pos 119): [10001] (range 3) user-defined error exception

 

Although I found some point in the thread but it was not so clear:

http://scn.sap.com/community/developer-center/hana/blog/2014/06/24/exception-handling-of-sap-hana-sqlscript-procedure

 

i.e.

The difference between SIGNAL and RESIGNAL is that when using SIGNAL, you must point out the SQL ERROR CODE or CONDITION of the exception. But RESIGNAL can be used in the action part of an EXIT HANDLER all alone. That is to say, RESIGNAL can be used to throw exception of the EXIT HANDLER catches to the caller. A user-defined exception can be catch by the corresponding EXIT HANDLER, or caught by the caller, same as an exception contains error code.


Here i don't understand the sentence highlighted in bold.


I'll be thankful to you all, if it can be explained in more simple words.


Thanks,

Sree


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>