Exception declaration is handled by the raise function.
Severity
Low
Some parts of the output code are omitted for clarity reasons.
Generate Procedures and Macros using JavasScript as the target language adding the following flag -t JavaScript or --PLTargetLanguage JavaScript
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:
IN -> Oracle_01.sql
-- 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:
OUT -> Oracle_01.sql
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
;
$$;
Some parts in the output codes are omitted, in order to make more readable.