Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

SAP HANA exception handling in procedure with DDL

$
0
0

Hi all,

 

Please consider the following simple HANA stored procedure:

 

CREATE PROCEDURE SP_TEST ( )     LANGUAGE SQLSCRIPT     SQL SECURITY DEFINER
AS
BEGIN     DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY;     CREATE TABLE TEMP (COL1 INT);     DROP TABLE TEMP;     SELECT 9/0 FROM DUMMY;
 END;

When this procedure is executed using CALL SP_TEST, the exception raised by the divide by zero operation is not handled, as per:

 

Started: 2015-11-13 13:13:57

 

Could not execute 'CALL SP_TEST' in 44 ms 429 µs .

 

[129]: transaction rolled back by an internal error: [129] "SP_TEST": line 12 col 2 (at pos 230): [129] (range 3): transaction rolled back by an internal error: division by zero undefined: at function /()

 

Now consider the following modified code:

 

CREATE PROCEDURE SP_TEST ( )     LANGUAGE SQLSCRIPT     SQL SECURITY DEFINER
AS
BEGIN     DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY;     --CREATE TABLE TEMP (COL1 INT);     --DROP TABLE TEMP;     SELECT 9/0 FROM DUMMY;
 END;

When this procedure is executed in the same fashion, the exception is handled correctly, as per:

13-11-2015 13-32-31.png

 

From my testing and observation, it appears that once a DDL statement is executed within a stored procedure, any subsequent exception raised will not be handled.  If the exception is raised prior to the execution of a DDL statement, the exception is handled.

 

Local temporary tables do not appear to cause this issue, but global temporary table do.  And of course, DML statements also do not cause the issue.

 

This behaviour has been observed on SPS 8 Rev. 82.

 

Can anyone tell me if a) this behaviour is a product bug, and if so in what revision is it resolved, or b) this behaviour is by design, and if so why?

 

Thanks,

 

Chris.


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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