WHILE STATEMENT

Executes a list of SQL statements in a loop until the WHILE condition is met

Grammar Syntax

WHILE boolean_expression DO
  sql_statement_list
END WHILE;

Click here to go to the BigQuery specification for this syntax.

Sample Source Patterns

Without block

DECLARE x INT64 DEFAULT 0;
WHILE x < 5 DO
  SET x = x + 1;
END WHILE;
INSERT INTO SNOWPUBLIC.table_while_1 VALUES (x);
SET x = 0;
BEGIN
  WHILE ((
    SELECT
      $x < 5
  )) DO
    SET x = $x + 1;
  END WHILE;
END;
INSERT INTO SNOWPUBLIC.table_while_1
VALUES ($x);

Inside procedure

Last updated

Was this helpful?