The following article describes how to control the actual application code lines of Oracle PL/SQL program flows, and the conditional control and cyclic control structures supported by PL/SQL. The following describes the main content of the article. The following describes the specific content,
Syntax and usage
- IF..THEN
Syntax:
- IF condition THEN
- Statements 1;
- Statements 2;
- ....
- END IF
The IF statement determines whether the condition is TRUE. IF yes, the statement after THEN is executed. IF the condition is false or NULL, the statement between THEN and end if is skipped, execute the statement after end if.
- IF..THEN...ELSE
Syntax:
- IF condition THEN
- Statements 1;
- Statements 2;
- ....
- ELSE
- Statements 1;
- Statements 2;
- ....
- END IF
IF the condition is TRUE, the statement between THEN and ELSE is executed. Otherwise, the statement between ELSE and end if is executed.
IF can be nested, you can use IF or IF. ELSE statements in IF or IF. ELSE statements.
- if (a>b) and (a>c) then
- g:=a;
- else
- g:=b;
- if c>g then
- g:=c;
- end if
- end if
- IF..THEN..ELSIF
-
Syntax:
- IF condition1 THEN
- statement1;
- ELSIF condition2 THEN
- statement2;
- ELSIF condition3 THEN
- statement3;
- ELSE
- statement4;
- END IF;
- statement5;
If the condition condition1 is TRUE, execute statement1, and then execute statement5; otherwise, judge whether condition2 is TRUE; if it is TRUE, execute statement2, and then execute statement5. The Condition 3 is the same. If condition1, if neither condition2 nor condition3 is true, statement4 is executed and statement5 is executed. The above content is an introduction to some of the Oracle PL tutorials.
Article by: http://www.programbbs.com/doc/class10-3.htm