Explain how to use various control statements in Oracle databases, and explain how to use oracle

Source: Internet
Author: User

Explain how to use various control statements in Oracle databases, and explain how to use oracle

The use of various control statements in the Oracle database is what we will introduce in this article, including some logical control statements, the use of Case when, the use of While, and the use of, next we will introduce this part one by one, hoping to help you.

Logical control statements in Oracle

If elsif else end if  set serverout on;  declare per_dep_count number;  begin  select count(*) into 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;  end; 

Case when can be used in two ways:

Method 1

declare per_dep_count number;  begin  select count(*) into 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;  

Method 2

declare per_dep_count number;  begin  select count(*) into 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;  

While usage 

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

declare v_id number:=0;  begin  for v_id in 1..5 loop  dbms_output.put_line(v_id);  end loop;  end; 

The usage of various control statements in the Oracle database is introduced here. I hope this introduction will be helpful to you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.