Thanks for the question.
Asked: July 21, 2022 - 9:24 am UTC
Last updated: July 29, 2022 - 3:34 pm UTC
Version: 12
Viewed 10K+ times! This question is
SQL> set serverout on SQL> declare 2 factor int := 4; 3 begin 4 for i in 1 .. 12 loop 5 dbms_output.put_line(factor*i); 6 end loop; 7 end; 8 / 4 8 12 16 20 24 28 32 36 40 44 48 PL/SQL procedure successfully completed.
SQL> with factor as 2 ( select 4 f from dual) 3 select f*rownum 4 from factor 5 connect by level <= 12; F*ROWNUM ---------- 4 8 12 16 20 24 28 32 36 40 44 48 12 rows selected.
Rajeshwaran, Jeyabal, July 27, 2022 - 2:55 pm UTC
SQL> variable n number SQL> exec :n := 4; PL/SQL procedure successfully completed. SQL> ed 1 select * 2 from dual 3 model 4 return updated rows 5 dimension by (0 x) 6 measures( 0 val ) 7 rules( 8 val[for x from 1 to 10 9* increment 1] = cv(x) * :n ); SQL> / X VAL _____ ______ 1 4 2 8 3 12 4 16 5 20 6 24 7 28 8 32 9 36 10 40 10 rows selected. SQL>
declare factor int := 4; begin for i in factor .. ( factor * 12 ) by factor loop dbms_output.put_line ( i ); end loop; end; / 4 8 ... 44 48
The Oracle documentation contains a complete SQL reference.