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
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
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