Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime 16.3 and above
Terminates the execution of an iteration of a looping statement and exits the loop.
This statement may only be used within a compound statement.
Syntax
LEAVE label
Parameters
-
The label identifies a statement to leave that directly or indirectly contains the
LEAVEstatement.
Examples
-- sum up all odd numbers from 1 through 10
-- Iterate over even numbers and leave the loop after 10 has been reached.
> BEGIN
DECLARE sum INT DEFAULT 0;
DECLARE num INT DEFAULT 0;
sumNumbers: LOOP
SET num = num + 1;
IF num > 10 THEN
LEAVE sumNumbers;
END IF;
IF num % 2 = 0 THEN
ITERATE sumNumbers;
END IF;
SET sum = sum + num;
END LOOP sumNumbers;
VALUES (sum);
END;
25