SSC-EWI-OR0052
Exception declaration is handled by the raise function.
Severity
Low
Description
Exceptions can be defined in both languages, Oracle and Snowflake, but the RAISE function is designed to do declaration, assignment, and throw the error. This is why the Exception declaration is commented out and the warning is displayed.
Example Code
Input Code:
-- Additional Params: -t JavaScript
CREATE OR REPLACE PROCEDURE EXCEPTION_DECLARATION_SAMPLE AUTHID DEFINER IS
NEW_EXCEPTION EXCEPTION;
PRAGMA EXCEPTION_INIT(NEW_EXCEPTION, -63);
BEGIN
IF true THEN
RAISE NEW_EXCEPTION;
END IF;
EXCEPTION
WHEN NEW_EXCEPTION THEN
--Handle Exceptions
END;
Output Code:
CREATE OR REPLACE PROCEDURE EXCEPTION_DECLARATION_SAMPLE ()
RETURNS STRING
LANGUAGE JAVASCRIPT
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "oracle", "convertedOn": "12/16/2024", "domain": "test" }}'
EXECUTE AS CALLER
AS
$$
!!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'PlInvokerRightsClause' NODE ***/!!!
//AUTHID DEFINER
null
// SnowConvert Helpers Code section is omitted.
try {
!!!RESOLVE EWI!!! /*** SSC-EWI-OR0052 - EXCEPTION DECLARATION IS HANDLED BY RAISE FUNCTION ***/!!!
/* NEW_EXCEPTION EXCEPTION */
;
!!!RESOLVE EWI!!! /*** SSC-EWI-OR0051 - PRAGMA EXCEPTION_INIT IS NOT SUPPORTED ***/!!!
/* PRAGMA EXCEPTION_INIT(NEW_EXCEPTION, -63) */
;
if (true) {
RAISE(-63,`NEW_EXCEPTION`,`NEW_EXCEPTION`);
}
} catch(error) {
switch(error.name) {
case `NEW_EXCEPTION`: {
break;
}
default: {
throw error;
break;
}
}
}
//Handle Exceptions
;
$$;
Recommendations
If you need more support, you can email us at snowconvert-support@snowflake.com
Last updated