Home > database >  Help, how to write an iteration statement?
Help, how to write an iteration statement?

Time:09-25

Such as title, there is no great god help, ha, ha, ha,

CodePudding user response:

Baidu so many examples

CodePudding user response:

http://blog.sina.com.cn/s/blog_710faf420100zc6v.html

Oracle three Loop (For a While, Loop)



Loop, the for
It

1. GOTO usage of ORACLE
DECLARE
X number;
The BEGIN
X:=9;
- cycle point
X: x=1;
DBMS_OUTPUT. PUT_LINE (X);
IF X> 0
THEN
GOTO repeat_loop; - when the value of x is less than 9, will goto repeat_loop
END IF;
END;


2, the ORACLE of the FOR loop USES
DECLARE
X number; Declarations of variables
-The BEGIN
X:=1; - to the initial value
FOR X IN REVERSE 1.. 10 LOOP - reverse from big to small
DBMS_OUTPUT. PUT_LINE (' within: x='| | x);
END LOOP;
DBMS_OUTPUT. PUT_LINE (' end loop: x='| | x); - x=1
END;


3, the ORACLE of the WHILE loop usage
DECLARE
X number;
The BEGIN
X:=0;
WHILE x<9 LOOP
X:=x + 1;
DBMS_OUTPUT. PUT_LINE (' within: x='| | x);
END LOOP;
DBMS_OUTPUT. PUT_LINE (' f x='| | x);
END;


4, LOOP circulating usage of ORACLE
DECLARE
X number;
The BEGIN
X:=0;
LOOP
X:=x + 1;

EXIT the WHEN x> 9.
DBMS_OUTPUT. PUT_LINE (' within: x='| | x);
END LOOP;
DBMS_OUTPUT. PUT_LINE (' f x='| | x);
END;
/

CodePudding user response:

http://bbs.csdn.net/topics/391996442

CodePudding user response:

While conditions

Loop

/* conditions after the establishment of executive */

Exit the when a> 10 - when a> 10 when to exit the loop

end loop;


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Exit: used for directly out of the current cycle

Exit the when: when meet certain conditions to exit the current cycle

Continue: directly to the end of this cycle to the next cycle

Comtinue when: meet certain conditions over the cycle to the next cycle

CodePudding user response:

http://blog.csdn.net/w67995822/article/details/69831454

My blog, you can see,

CodePudding user response:

- perform 1 + 2 + 3 +... The value of + 100
Declare
Counter number (3) :=0;
SumResult number:=0;
The begin
Loop
Counter: + 1=counter;
SumResult:=sumResult + counter;
Exit the when counter & gt;=100;
end loop;
Dbms_output. Put_line (' the result is: '| | to_char (sumResult));
end;
Exit: used for directly out of the current cycle

Exit the when: when meet certain conditions to exit the current cycle

Continue: directly to the end of this cycle to the next cycle

Comtinue when: meet the certain conditions will end the cycle to the next cycle

- for the use of the
Declare
Counter number (3) :=0;
SumResult number:=0;
The begin
For the counter in 1.. 100 loop
SumResult:=sumResult + counter;
end loop;
Dbms_output. Put_line (' the result is: '| | to_char (sumResult));
end;

CodePudding user response:

 
The loop statement
[& lt; & lt; label_name & gt; & gt;]
LOOP
The statement...
END LOOP [label_name]
[grammar specification]
: the structure of the LOOP label, it is optional,
LOOP: LOOP cycle began to flag,
Statement: the LOOP statement execution sequence of statements,
END LOOP: the END of the LOOP cycle logo, can add the LOOP structure,
For statement
[& lt; & lt; label_name & gt; & gt;]
For variable_name (REVERSE) in lower_limit.. Upper_limit loop
The statement;
END LOOP;
[grammar specification]
Variable_counter_name: loop counter, it is a variable, it can get the current cycle index,
Lower_limit: circulation range of subscript,
Upper_limit: circulation range of superscript,
The subscript and superscript between ".. "Can't omit,
While statement
[& lt; & lt; label_name & gt; & gt;]
WHILE condition_expression loop
The statement...
end loop;
[grammar specification]
Condition_expression: Boolean expressions,
Statement: sequence, when condition_expression is TRUE, the statement sequence executive power can be obtained,