MSCINF0007

Exception system variables are not supported in Snowflake.

This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.

Severity

None

Description

This EWI is added when a statement references exception variables in BigQuery because they are not supported in Snowflake, and the content of these variables is quite different from the exception variables allowed in Snowflake. For more information please refer to Handling Exceptions in Snowflake.

Code Example

Input Code:

CREATE OR REPLACE PROCEDURE test.proc1()
BEGIN
  SELECT 1/0;
EXCEPTION WHEN ERROR THEN
  SELECT
    @@error.message as message,
    @@error.stack_trace as stack_trace,
    @@error.statement_text as statement_text,
    @@error.formatted_stack_trace as formatted_stack_trace;
END;

Output Code:

CREATE OR REPLACE PROCEDURE test.proc1()
RETURNS VARCHAR
LANGUAGE SQL
EXECUTE AS CALLER
AS
$$
  BEGIN
    SELECT 1/0;
  EXCEPTION WHEN OTHER THEN
--    --** MSC-INFORMATION - MSCINF0007 - EXCEPTION SYSTEM VARIABLES ARE NOT SUPPORTED IN SNOWFLAKE. **
--  SELECT
--    @@error.message as message,
--    @@error.stack_trace as stack_trace,
--    @@error.statement_text as statement_text,
--    @@error.formatted_stack_trace as formatted_stack_trace;
    RETURN OBJECT_CONSTRUCT('SQLERRM', SQLERRM, 'SQLCODE', SQLCODE, 'SQLSTATE', SQLSTATE);
  END;
$$;

Recommendations

  • Snowflake has three built-in variables that provide information about the exception:

    1. SQLSTATE: This is a 5-character code modeled on the ANSI SQL standard SQLSTATE .

    2. SQLERRM: This is an error message.

    3. SQLCODE: This is a 5-digit signed integer.

  • If you need more support, you can email us at snowconvert-support@snowflake.com

Last updated