Translation reference to convert DECLARE statement to Snowflake Scripting
Description
DECLARE statement is an optional part of the PL/pgSQL block statement. It allows the creation of variables, constants, procedures declarations and definitions, and functions declarations and definitions. For more information, please refer to PostgreSQL Declarations.
Sample Source Patterns
Empty declaration block
In case the declaration block is empty without variable declarations, it will be removed.
CREATEFUNCTIONFOO1(i integer, j varchar) RETURNSINTEGERAS $$DECLAREBEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;
CREATEFUNCTIONFOO1(i integer, j varchar) RETURNSINTEGERAS $$BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;
Multiple variable declarations block
If the declare keyword is at the beginning of each variable declaration, it will be removed.
CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLAREDECLARE i integer=20;DECLARE j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;------------------------------------------------------------------------------CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLARE i integer=20;DECLARE j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;
CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLARE i integer=20; j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;------------------------------------------------------------------------------CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLARE i integer=20; j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;
The following declaration block is fully supported by Snowflake.
CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLARE i integer=20; j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;
CREATEFUNCTIONFOO() RETURNSINTEGERAS $$DECLARE i integer=20; j integerdefault30;BEGININSERT INTO TABLE1 VALUES (i,j);RETURN i +1;END;$$ LANGUAGE plpgsql;