SSC-EWI-OR0052

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":1, "minor":0},{"attributes":{"component":"oracle"}}'
EXECUTE AS CALLER
AS
$$
  //AUTHID DEFINER
  !!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'PlInvokerRightsClause' NODE ***/!!!
  null
  // SnowConvert Helpers Code section is omitted.

  /* ** SSC-EWI-OR0052 - EXCEPTION DECLARATION IS HANDLED BY RAISE FUNCTION ** */
  /*   NEW_EXCEPTION EXCEPTION */
  ;
  /* ** SSC-EWI-OR0072 - PROCEDURAL MEMBER PRAGMA DECLARATION NOT SUPPORTED. ** */
  /*   PRAGMA EXCEPTION_INIT(NEW_EXCEPTION, -63) */
  ;
  try {
    if (true) {
      RAISE(-6512,`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.

Recommendations

Last updated