REPEAT STATEMENT

Repeatedly executes a list of zero or more SQL statements until the boolean condition at the end of the list is TRUE.

Grammar Syntax

REPEAT
  sql_statement_list
  UNTIL boolean_condition
END REPEAT;

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

Sample Source Patterns

CREATE OR REPLACE PROCEDURE proc1()
BEGIN 
DECLARE x INT64 DEFAULT 0;
REPEAT
  SET x = x + 1;
  UNTIL x >= 3
END REPEAT;
    INSERT INTO table1 VALUES (x);
RETURN;
END;
CREATE OR REPLACE PROCEDURE test.proc1 ()
RETURNS VARCHAR
LANGUAGE SQL
EXECUTE AS CALLER
AS
$$
  DECLARE x INT DEFAULT 0;
  BEGIN
  REPEAT
    x := x + 1;
    UNTIL ( x >= 3 )
  END REPEAT;
      INSERT INTO test.table1
  VALUES (:x);
  RETURN 'SUCCESS';
  END;
$$;

Last updated