RAISE_APPICATION_ERROR

Translation reference for the raise_application_error statement.

General description

The procedure RAISE_APPLICATION_ERROR lets you issue user-defined ORA- error messages from stored subprograms. That way, you can report errors to your application and avoid returning unhandled exceptions (Oracle documentation).

Oracle syntax

raise_application_error(
      error_number, message[, {TRUE | FALSE}]);

The error_number is a negative integer in the range -20000 .. -20999 and message is a character string up to 2048 bytes long.

If the optional third parameter is TRUE, the error is placed on the stack of previous errors. If the parameter is FALSE (the default), the error replaces all previous errors.

The equivalent statement in Snowflake is the RAISE clause, nevertheless, it is required to declare the user-defined exception as a variable before calling the RAISE statement for it.

Snowflake Syntax

<exception_name> EXCEPTION [ ( <exception_number> , '<exception_message>' ) ] ;

For more information review the following Snowflake documentation.

Sample Source Patterns

1. Exception in functions without declaring section

In this scenario, the function without a declaring section is translated to a procedure with the exception declaration. Please note that:

  • The exception variable name is declared in upper case.

  • The exception variable name is based on the description and an ending is composed of an exception code name followed by a consecutive number.

  • The declaring section is created even though the initial function or procedure does not contain it.

Oracle

Snowflake

2. Exception code number outside limits

The following example shows the translation commented out in the procedure body. It is because the code is outside the applicable code limits in Snowflake. The solution is to change the exception code for an available code in the query section.

Oracle

Snowflake

3. Exception stack functionality

The exception stack functionality is not supported in Snowflake and is removed from the exception declaration.

Oracle

Snowflake

4. Multiple exceptions with the same exception code

Multiple exceptions with the same can coexist in the declaring section and raise statements.

Oracle

Snowflake

Known Issues

  1. SQLREM function may be reviewed.

  2. Exception code number outside the applicable limits in Snowflake has to be changed to an available code exception.

  3. Add to a stack of errors is not supported.

MSCEWI3099: The exception code exceeds the Snowflake Scripting limit

MSCEWI3066: Add to a stack of errors is not supported, the boolean argument was removed.

Last updated

Was this helpful?