Getting error in BEGIN END block error line variable cannot have its type inferred from initializer

1.74K viewsErrors and TroubleshootingSnowflake Errors
0

I am getting this error.
snowflake SQL compilation error: error line variable cannot have its type inferred from initializer

Here is the code:

DECLARE error_exception_stuff exception (-20887, ‘Configuration Issue. Invalid Account’);

BEGIN
LET CURRENT_ACCOUNT_LOCATOR := (SELECT CURRENT_ACCOUNT());
LET ORG_AND_ACCOUNT_NAME := (SELECT UPPER(SPLIT_PART(JSONFUN[1].”host”::VARCHAR,’.’,1))
CORRECT_ORG_DOT_ACCOUNT_NAME FROM
(SELECT PARSE_JSON(SELECT SYSTEM$WHITELIST()) JSONFUN)
WHERE JSONFUN[0].”host”::VARCHAR like LOWER($CURRENT_ACCOUNT_LOCATOR) || ‘%’
AND JSONFUN[1].”type”::VARCHAR = ‘SNOWFLAKE_DEPLOYMENT_REGIONLESS’) ;
SELECT ‘ORG_AND_ACCOUNT_NAME=’ || $ORG_AND_ACCOUNT_NAME;
LET CONFIG_SET VARCHAR := (SELECT $ORG_AND_ACCOUNT_NAME);
IF (CONFIG_SET IS NULL ) THEN
RAISE error_exception_stuff;
ELSE
RETURN ‘PROCEED’;
END IF;
END;

Can anyone help me with how to fix this?

Charles Sardou Asked question November 11, 2022