Using Oracle stored procedures in the middle of the target

Source: Internet
Author: User

I. Using a FOR loop cursor:

1. Define a cursor (a cursor is a small collection)

2. Defining cursor Variables

3. Using a For loop cursor

Declare  --Define cursor c_job cursor  c_job is    select Empno, ename, Job, Sal from emp where job = ' MANAGER ';      ---Define cursor variable c_row  c_row c_job%rowtype;begin  -loop cursor, c_row the value of the loop with the cursor variable for  c_row in C_job loop    Dbms_ Output.put_line (C_row.empno | | '-' || C_row.ename | | '-' ||                         C_row.job | | '-' || C_row.sal);  End Loop;end;

2. Fetch cursors:

Must be explicitly turned on and off when used

Declare  --Define cursor c_job cursor  c_job is    select Empno, ename, Job, Sal from emp where job = ' MANAGER ';  --Define cursor variable c_row  c_row c_job%rowtype;begin  open c_job;  Loop    -Extracts a row of data to C_row    fetch c_job into C_row;        --the interpretation of whether to extract the value, the value is not taken out of exit when    C_job%notfound;    Dbms_output.put_line (C_row.empno | | '-' || C_row.ename | | '-' ||                         C_row.job | | '-' || C_row.sal);  End Loop;    --Closing the cursor close  c_job;end;

Using Oracle stored procedures in the middle of the target

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.