User Define Exception Procedure

HI Team

i am trying to create a user define an exception and I am getting an error message can some help about user define and not got the correct example in the document also

Logic is simple v_int>=5 then need to rise the user define an exception

> create or replace PROCEDURE zsum_error2(v_int int(5)) AS 
> DECLARE  
> I INT;
> BEGIN 
> 	IF v_int >= 5 THEN 
>  		RAISE user_exception("abort");
>  	null;
> 	ELSE
> 	ECHO SELECT V;
> 	end IF;
> EXCEPTION
>   WHEN ER_USER_RAISE THEN
>     ROLLBACK;
>     IF exception_message() = "retry" THEN
> 	echo select 'error';
>     ELSIF exception_message() = "abort" THEN
>       RAISE;
>     END IF;
> 
> END;

CALL zsum_error2(3)
SQL Error [1054] [42S22]: (conn=11102149) Unhandled exceptio

Your code does a RAISE in the ELSIF block, that is not caught. If you don’t catch it, you’ll get an error at the top level. So either don’t RAISE there, or have the caller to zsum_error2 catch the exception you raise.

1 Like