Oracle conditional branch statements are frequently used. The following describes the syntax of Oracle conditional branch statements in detail. If you are interested in this, take a look.
Oracle condition branch statements are used to select the operation to be executed based on specific conditions. PL/SQL provides three Oracle condition branch statements: if-then, if-then-else, if-then-elsif.
Syntax:
- if conditions then
- statements;
- [elseif conditions then
- statements;]
- [else
- statements;]
- end if;
1. if-then example
It is used to perform a single condition judgment. If a specific condition is met, the corresponding operation is performed. If the condition is not met, the condition branch statement is exited.
- Declare
- V_count number;
- Begin
- Select count (*) into v_count from cip_temps;
- If (v_count> 0) then
- Dbms_output.put_line ('v _ cont value: '| v_count );
- End if;
- End;
- /
2. if-then-else example
It is used to perform dual-condition judgment. If a specific condition is met, one group of operations is performed. If the condition is not met, another group of operations is performed.
- Declare
- V_count number;
- Begin
- Select count (*) into v_count from cip_temps;
- If (v_count> 11) then
- Dbms_output.put_line ('v _ cont value: '| v_count );
- Else
- Dbms_output.put_line ('v _ count value: '| v_count );
- End if;
- End;
- /
3. if-then-elsif example
It is used to perform multi-condition judgment. If condition 1 is met, the first group of operations will be executed. If condition 2 is met, the second group of operations will be executed, and so on, if none of the conditions are met, the operation that does not meet the conditions is executed.
- Declare
- V_count number;
- Begin
- Select count (*) into v_count from cip_temps;
- If (v_count> 10) then
- Dbms_output.put_line ('If operation ___ v_cont value: '| v_count );
- Elsif (v_count = 10) then
- Dbms_output.put_line ('elsif operator ____ v_count value: '| v_count );
- Else
- Dbms_output.put_line ('else operator ____ v_cout value: '| v_count );
- End if;
- End;
- /
Oracle authorization statement
Statement of Oracle cyclic statements
Introduction to Oracle user creation syntax
Oracle Default User Password Problems
Common Oracle cursor attributes