Usage of midstream targets in Oracle databases

Source: Internet
Author: User
Definition of a cursor: The Role of a cursor has been mentioned in the previous article. If the query result contains more than one row, you need to use a cursor. In the article rdquo; Introduction to PLSQL in Oracle Data

Definition of a cursor: The Role of a cursor has been mentioned in the previous article. If the query result contains more than one row, you need to use a cursor. In the article rdquo; PL/SQL in Oracle Data

Cursor definition:

The role of a cursor

As mentioned in the previous article, if the query result contains more than one row, a cursor is required. For more information about PL/SQL in Oracle data, see.

Procedure:

Define a cursor

Syntax: CURSOR cursor_name is select _ statement;

Open cursor

Syntax: open cursor_name;

Extract data

Using the fetch keyword, the record of the current row is captured and the record pointer is moved down to a row. Just like the ResultSet in JdbC.

Syntax: fetch cursor_name into variable1, variable2.

Some attributes of the cursor

Close cursor

Syntax: close cursor_name

The sample code is as follows:

Common method:

--- Use of cursors
Declare
-- Define a cursor to extract all tab_stu data
Cursor c_tab_stu is
Select * from tab_stu;

R_tab_stu tab_stu % rowtype; -- use rowtype to store cursor data

Begin
-- Open the cursor
Open c_tab_stu;
-- Extract data
Fetch c_tab_stu into r_tab_stu;
Dbms_output.put_line ('stu _ id: '| r_tab_stu.stu_id );
Dbms_output.put_line ('stu _ name: '| r_tab_stu.stu_name );
Dbms_output.put_line ('stu _ age: '| r_tab_stu.stu_age );
-- Close the cursor
Close c_tab_stu;
End;

Next, let's take a look at the highlights of page 2nd:

Related reading:

Comparison of Three Types of cursor Cycle Efficiency in PL/SQL

Use of Oracle Advanced explicit cursor

Use of insert in Oracle stored procedures, including the use of cursors

Usage of Oracle display cursor

Simple use of Oracle cursor

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.