RAISE (Snowflake Scripting) | Snowflake Documentation (original) (raw)

Raises an exception.

For more information about exceptions, see Handling exceptions.

See also:

EXCEPTION

Syntax

Where:

Examples

This creates and raises (but does not catch) a simple exception:

CREATE PROCEDURE thrower() RETURNS VARCHAR LANGUAGE SQL AS DECLAREMYEXCEPTIONEXCEPTION;BEGINRAISEMYEXCEPTION;END;DECLARE MY_EXCEPTION EXCEPTION; BEGIN RAISE MY_EXCEPTION; END;DECLAREMYEXCEPTIONEXCEPTION;BEGINRAISEMYEXCEPTION;END; ;

Here is the call to the stored procedure that raises the exception:

Here is the output of executing the stored procedure that raises the exception:

-20000 (P0001): Uncaught exception of type 'MY_EXCEPTION' on line 5 at position 8

The next example is similar to the preceding example, but uses an exception for which the user defined a custom exception number and exception message:

DECLARE
    MY_EXCEPTION EXCEPTION (-20002, 'Raised MY_EXCEPTION.');

Here is the output of executing the stored procedure that raises the exception:

-20002 (P0001): Uncaught exception of type 'MY_EXCEPTION' on line 7 at position 8 : Raised MY_EXCEPTION.

For more examples, see the examples forhandling an exception.