User Tools

Site Tools


Sidebar

HPL/SQL is included to Apache Hive since version 2.0

for-range

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== FOR Statement (Integer Range) - PL/HQL Reference ====== FOR statement executes one or more statements repeatedly for the specified range of integer values. Syntax: <code language=sql> FOR index IN [REVERSE] lower_bound..upper_bound [BY | STEP increment] LOOP statements END LOOP; </code> **Notes:** * //index// - Implicitly declared integer variable * If REVERSE is specified the index is decreased * If specified, BY (or STEP) define the iteration step, default is 1 **Examples:** <code language=sql> FOR i IN 1..10 LOOP -- i will have values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 END LOOP; </code> <code language=sql> FOR i IN REVERSE 10..1 LOOP -- i will have values: 10, 9, 8, 7, 6, 5, 4, 3, 1, 1 END LOOP; </code> <code language=sql> FOR i IN 1..10 BY 2 LOOP -- i will have values: 1, 3, 5, 7, 9 END LOOP; </code> **Compatibility:** Oracle, PostgreSQL and Netezza. **Version:** PL/HQL 0.01