Oracle PL/SQL - Simulating STEP Clause in FOR LOOP Statement

Introduction

To simulate the STEP clause in PL/SQL, multiply each reference to the loop index by the desired increment.

Demo

SQL>
SQL>-- from   w ww  .  j a v  a 2 s . c o m
SQL> DECLARE
  2    step  PLS_INTEGER := 5;
  3  BEGIN
  4    FOR i IN 1..3 LOOP
  5      DBMS_OUTPUT.PUT_LINE (i*step);
  6    END LOOP;
  7  END;
  8  /
5
10
15

PL/SQL procedure successfully completed.

SQL>

Related Topic