Snowflake Scripting
Snowflake Scripting
-- Call Procedure
call myprocedure();
DECLARE
radius_of_circle FLOAT;
area_of_circle FLOAT;
BEGIN
radius_of_circle := 3;
area_of_circle := pi() * radius_of_circle * radius_of_circle;
RETURN area_of_circle;
END;
EXECUTE IMMEDIATE $$
DECLARE
radius_of_circle FLOAT;
area_of_circle FLOAT;
BEGIN
radius_of_circle := 3;
area_of_circle := PI() * radius_of_circle * radius_of_circle;
RETURN area_of_circle;
END;
$$
;
-- Branching Construct
BEGIN
LET count := 1;
IF (count < 0) THEN
return 'negative value';
ELSEIF (count = 0) THEN
return 'zero';
ELSE
return 'positive value';
END IF;
END;
--Looping
BEGIN
CREATE OR REPLACE TABLE my_values(id integer);
-- Insert 3 rows into a table.
INSERT INTO my_values VALUES (1), (2), (3);
-- SQLROWCOUNT is not affected by statements
-- that are not DML statements (e.g. SELECT statements).
SELECT * from my_values;
-- Returns the number of rows affected by
-- the last DML statement (the INSERT statement).
RETURN SQLROWCOUNT;
-- RETURN SQLFOUND; true if the last DML statement affected one or more rows.
-- RETURN SQLNOTFOUND , true if the last DML statement affected zero rows.
END;
-- Result Set
-- Exception Handling
-- Cursor Handling