Differences between oracle cursor and cursor variable

Source: Internet
Author: User

Oracle cursors are often used. The following describes the differences between oracle cursors and cursors. If you are interested in oracle cursors, take a look.

Oracle cursor is a named workspace in the database. When the cursor is declared, it is associated with a fixed SQL statement. It is known at the time of compilation and static. it always points to the same query workspace.
The cursor variable can be associated with different SQL statements at runtime, and different SQL statements can be used at runtime. It can reference different workspaces.

Oracle cursors and cursors cannot replace each other.

How to define the cursor type

TYPE ref_type_name is ref cursor [RETURN return_type];

Declare cursor variable

Cursor_name ref_type_name;
 
Ref_type_name is the type of our CURSOR to be used when the CURSOR variable is declared later (the custom CURSOR type, that is, the CURSOR is the system default, and the ref_type_name is what we define ); return_type indicates a row in the database table or a record type.
TYPE ref_type_name is ref cursor return employee % TYPE
RETURN is optional. If there is a strong type, errors can be reduced. If no return is a weak reference, it has better flexibility.
 
You cannot declare the cursor variable in the header. Note that you can define the cursor type. Pay attention to the differences between the two.
You can declare a cursor variable as a parameter in the form of a function or process.

% Type a column TYPE

% ROWTYPE Row Type

Control oracle cursor Variables

OPEN-FOR (OPEN the cursor variable, connected to multi-row queries) FETCH (get row data from the result set), close (close the cursor variable)
The bulk collect clause extracts the rows in the cursor variable into a collection at a time.
 

Oracle cursor expressions and table functions

Use instances of Oracle stored procedures

Oracle command line custom editor vi

Implementation of oracle command line Logon

Oracle queries table space usage

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.