Reference Guide > TDV SQL Script > SQL Script Statement Reference > RAISE
 
RAISE
The RAISE statement is used in SQL Script to raise an exception.
Syntax
RAISE [<exceptionName>] [VALUE [<valueExpression>]]
Remarks
The value expression must resolve to a string. (See Value Expressions.)
The <exceptionName> can be any exception that is defined in the current scope, a parent scope, or that has a qualified name (such as a system exception).
A name is required if this statement is outside of an exception handler. When inside an exception handler and when no name is used, the current exception is re-raised.
The <valueExpression> can optionally be set on an exception. If not present, the value defaults to NULL. The value be implicitly cast (if necessary) to be assigned into the exception.
You can change the value of an exception when re-raising it by including the VALUE clause but no exception name.
Examples
PROCEDURE square (IN x INTEGER)
BEGIN
  DECLARE illegal_parameter_ex EXCEPTION;
 
  IF x IS NULL THEN
    RAISE illegal_parameter_ex;
  END IF;
 
...
END
 
PROCEDURE p (IN x INTEGER)
BEGIN
  DECLARE illegal_parameter_ex EXCEPTION;
 
  IF x < 0 THEN
    RAISE illegal_parameter_ex VALUE 'x must be > 0. x='||x;
  END IF;
 
...
END