The use of various control statements in Oracle database is the main content we want to introduce in this article, including some logic control statements, the use of cases, while and for use, and so on, we begin to introduce this part of the content, hope to be helpful to you.
Logical control statements in Oracle
If elsif else End if
set serverout on;
declare per_dep_count number;
Begin
Select COUNT (*) into the per_dep_count from EMP;
If Per_dep_count>0 then
dbms_output.put_line (' big Than 0 ');
elsif per_dep_count>5 then <span style= "Font-size:24px;color: #ff0000;" ><strong>--elsif NOT ElseIf!!!!
</strong></span> dbms_output.put_line (' Big Than 5 ');
else
dbms_output.put_line (' En? ');
End If;
The two ways in which case is used:
The first way of using
declare per_dep_count number;
Begin
Select COUNT (*) into the per_dep_count from EMP;
Case Per_dep_count when
1 then
dbms_output.put_line (' 1 ');
When 2 then
dbms_output.put_line (' 2 ');
else
dbms_output.put_line (' Else ');
End case;
End
The second way of using
declare per_dep_count number;
Begin
Select COUNT (*) into the per_dep_count from EMP;
Case when
per_dep_count=1 then
dbms_output.put_line (' 1 ');
When per_dep_count=2 then
dbms_output.put_line (' 2 ');
else
dbms_output.put_line (' Else ');
End case;
End
the use of while
declare v_id number:=0;
Begin while
v_id<5 loop
v_idv_id:=v_id+1;
Dbms_output.put_line (v_id);
End Loop;
End
For use
declare v_id number:=0;
Begin for
v_id in 1..5 loop
dbms_output.put_line (v_id);
End Loop;
End
About the use of various types of Oracle database control statements are introduced here, I hope this introduction can be harvested for you!