语法如下:FOR loopIndex IN [REVERSE] lowest_number..heighest_numberLOOP . . . 可以执行的语句END LOOP;使用这种循环的原因: 如果只想有限次的执行一段代码,又不想过早的结束循环,就可以使用数值型的FOR循环。【如】输出从satrtIndex开始到endIndex的数字PROCEDURE display_number( startIndexININTEGER...
reverse是逆转的意思,当有reverse关键字时,后面紧跟的值要反过来写,即大值..小值 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # 循环打印0-100之间的所有偶数 begin forvar_numin0..100 loop if mod(var_num,2) = 0then dbms_output.put_line(var_num); endif; endloop;...
2 FOR循环用法,以下是SQL源码:DECLARE x number; --声明变量BEGIN x := 1; --给初值 FOR x IN REVERSE 1 .. 10 LOOP --reverse由大到小 DBMS_OUTPUT.PUT_LINE('x=' || x); END LOOP; DBMS_OUTPUT.PUT_LINE('end loop x=' || x); --x=1END;3 WHILE循环用法,以...
REVERSE "REVERSE"(不是21c添加的),为对后面的元素进行倒序排列 beginforiinREVERSE1..5loopdbms_output.put_line(i);endloop;end;/---54321 iteration_control BY (stepped_control) 先看例子 SETSERVEROUTPUTON;DECLARETYPEt_tabISTABLEOFVARCHAR2(10)INDEXBYpls_integer;l_tab t_tab :=t_tab(foriin1..10...
DECLARE x number; --声明变量BEGIN x := 1; --给初值 FOR x IN REVERSE 1 .. 10 LOOP --reverse由大到小 DBMS_OUTPUT.PUT_LINE('x=' || x); END LOOP; DBMS_OUTPUT.PUT_LINE('end loop x=' || x); --x=1END; WHILE循环用法,以下是SQL源码: ...
VBA For Next Loop Flow Diagram Few Simple Examples of For Loop In VBA Writing a Nested For Loop Reverse For Loop in VBA Infinite Loop Using a For Loop How to Break Out or Exit of a For Loop Few Practical Examples of VBA For Loop VBA For Each Loop Syntax of a VBA For Each Loop Ho...
5 FOR X IN REVERSE 1 .. 10 LOOP 6 --reverse由大到小 7 DBMS_OUTPUT.PUT_LINE('内:x=' || x); 8 END LOOP; 9 DBMS_OUTPUT.PUT_LINE('end loop:x=' || X); --x=1 10 END; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
FOR vc IN REVERSE 1..9 LOOP DBMS_OUTPUT.PUT_LINE(vc); END LOOP; END; Output: Simply write the keyword REVERSE immediately after the keyword IN. So after executing the above command we get the below result. Input 3: Declare result_var NUMBER; ...
4. Awk For Loop Example: Print the fields in reverse order on every line. $ awk 'BEGIN{ORS="";}{ for (i=NF; i>0; i--) print $i," "; print "\n"; }' student-marks 77 84 78 2143 Jones 45 58 56 2321 Gondrol 37 38 2122 RinRao ...
The steps part in a for loop can either increase or decrease the value of a variable. Example: Reverse for Loop Copy for(int i = 10; i > 0; i--) { Console.WriteLine("Value of i: {0}", i); } Try it Output:Value of i: 10Value of i: 9Value of i: 8Value of i: 7Value...