Nested practices of Oracle multi-layer cursors

Source: Internet
Author: User

The following articles mainly introduce the nesting of Oracle multi-layer cursors and the specific concepts of Oracle cursors, the following articles mainly describe the actual operation steps for nesting Oracle multi-layer cursors, hoping to help you in this regard.

This is not the case. A cursor is not required in the stored procedure. It has input and output parameters. If the corresponding processing is performed in the process, the output parameters are returned. The cursor mainly serves to extract data cyclically. The cursor is divided into implicit cursor and explicit cursor.
For example, explicit cursor ):

CURSOR name is select statement;
.....
WHILE cursor name % found LOOP
.....
End loop;

The SELECT statement extracts a column of values, and then obtains a record each time for the following loop.

Implicit cursor ):

For cursor name in SELECT statement) loop
.....

.....
End loop;

The SELECT statement extracts a column of values, and then retrieves a record for the following loop each time.

Oracle multi-layer cursor nesting: Generally, multi-layer nesting can be replaced by combining several tables for query, but sometimes it cannot be replaced. For example, the second value to be queried is the first value to be queried before performing the like operation.

 
 
  1. declare  
  2. v_0 number;  
  3. v_1 number;  
  4. cursor c1 is select productordernumber from his_productorder@pro_crm where productid in (9000045516);  
  5. cursor c2 is select cust_order_id from suf_cust_order_q_his where cust_order_num like v_0||'%';  
  6. cursor c3 is select * from suf_work_order_q_his where cust_order_id=v_1;  
  7. begin  
  8. for i in c1 loop  
  9. v_0:=i.productordernumber;  
  10. for j in c2 loop  
  11. v_1:=j.cust_order_id;  
  12. for k in c3 loop  
  13. dbms_output.put_line(k.work_order_id||' '||k.status);  
  14. end loop;  
  15. end loop;  
  16. end loop;   

The above content is an introduction to Oracle multi-layer cursor nesting. I hope you will get some benefits.

Related Article

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.