LOOP
Description
A simple loop defines an unconditional loop that is repeated indefinitely until terminated by an EXIT or RETURN statement. (Redshift SQL Language Reference Conditionals: Simple Loop).
Simple Loop are partial supported by Snowflake.
Grammar Syntax
[<<label>>]
LOOP
statements
END LOOP [ label ];
Sample Source Patterns
Input Code:
CREATE OR REPLACE PROCEDURE simple_loop()
LANGUAGE plpgsql
AS $$
BEGIN
<<simple_while>>
LOOP
RAISE INFO 'I am raised once';
EXIT simple_while;
RAISE INFO 'I am not raised';
END LOOP;
RAISE INFO 'I am raised once as well';
END;
$$;
Output Code:
CREATE OR REPLACE PROCEDURE simple_loop ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "redshift", "convertedOn": "03/03/2025", "domain": "test" }}'
AS $$
BEGIN
LOOP
CALL RAISE_MESSAGE_UDF('INFO', 'I am raised once');
EXIT simple_while;
CALL RAISE_MESSAGE_UDF('INFO', 'I am not raised');
END LOOP simple_while;
CALL RAISE_MESSAGE_UDF('INFO', 'I am raised once as well');
END;
$$;
Known Issues
There are no known issues.
Related EWIs.
There are no related EWIs.
Last updated