User Tools

Site Tools


Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

loop

LOOP Statement - PL/HQL Reference

LOOP statement executes one or more statements until you exit the loop using EXIT, LEAVE or BREAK statements, or raising an exception.

Syntax:

[<<label>> | label:]
LOOP
  statements
END LOOP;

Examples:

-- Oracle, PostgreSQL, Netezza
LOOP
  count := count - 1;
  EXIT WHEN count = 0;
END LOOP;
-- DB2, Teradata, MySQL
lbl:
LOOP
  SET count = count - 1;
  IF count = 0 THEN
    LEAVE lbl;
  END IF;
END LOOP;

Compatibility: Oracle, Teradata, IBM DB2, MySQL, PostgreSQL and Netezza.