Statement of Oracle cyclic statements

Source: Internet
Author: User

There are many types of Oracle loop statements. The following describes how to write several common Oracle loop statements. If you are interested in Oracle loop statements, take a look.

Loop:

 
 
  1. create or replace procedure pro_test_loop is  
  2. i number;  
  3. begin  
  4. i:=0;  
  5. loop  
  6.   ii:=i+1;  
  7.   dbms_output.put_line(i);  
  8.   if i>5 then  
  9.     exit;  
  10.   end if;  
  11. end loop;  
  12. end pro_test_loop; 

While loop:

 
 
  1. create or replace procedure pro_test_while is  
  2. i number;  
  3. begin  
  4. i:=0;  
  5. while i<5 loop  
  6.   ii:=i+1;  
  7.   dbms_output.put_line(i);  
  8. end loop;  
  9. end pro_test_while; 

For Loop 1:

 
 
  1. create or replace procedure pro_test_for is  
  2. i number;  
  3. begin  
  4. i:=0;  
  5. for i in 1..5 loop  
  6.   dbms_output.put_line(i);  
  7. end loop;  
  8. end pro_test_for; 

For Loop 2:

 
 
  1. create or replace procedure pro_test_cursor is  
  2. userRow t_user%rowtype;  
  3. cursor userRows is  
  4. select * from t_user;  
  5. begin  
  6. for userRow in userRows loop  
  7.     dbms_output.put_line(userRow.Id||','||userRow.Name||','||userRows%rowcount);  
  8. end loop;  
  9. end pro_test_cursor;  

Oracle user syntax Modification

Solution to oracle user connection failure

Differences between oracle cursor and cursor variable

Show you the Oracle explicit cursor

Use instances of Oracle stored procedures

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.