Oracle Cursor Learning

Source: Internet
Author: User
Tags cursor library oracle cursor

1, what is a cursor?
① retrieves the result set from the table, and the mechanism from which each point points to a record for interaction.

The operations in the ② relational database are performed on the complete rowset.
The rowset returned by the SELECT statement includes all rows that satisfy the conditions listed in the WHERE clause of the statement. The complete rowset returned by the statement is called the result set.
Applications, especially interactive and online applications, treat a complete set of results as a unit that is not always valid.

These applications require a mechanism to process a row or rows at a time. The cursor is an extension of the result set that provides this mechanism.

Cursors are implemented through a cursor library. Cursor Library is a software that is often implemented as part of a database system or data access API,

A property (result set) used to manage the data returned from the data source. These properties include concurrency management, the location in the result set, the number of rows returned,

And whether you can move forward and/or backward in the result set (scrollable).

The cursor tracks the position in the result set and allows multiple actions to be performed on the result set line by row, which may be returned to the original table or not back to the original table.
In other words, a cursor conceptually returns a result set from a database-based table.

Because it indicates the current position in the result set, the cursor is named as if the cursor on the computer screen indicates the current position.

2, what is the function of the cursor?
① Specifies the location of a particular row in the result set.
② retrieves a row or successive rows based on the current result set location.
③ modifies the data in the row at the current position of the result set.
④ defines different levels of sensitivity for data changes made by other users.
⑤ can access the database programmatically.

3, why avoid using cursors?
① the most thing to consider when creating cursors is, "is there a way to avoid using cursors?" ”
Because cursors are inefficient, they should be rewritten if the cursor operates on more than 10,000 rows of data.
If a cursor is used, try to avoid the operation of table joins in the cursor loop.

What is the type of 4,oracle cursor?
① static cursor: A cursor that has a true (statically defined) result set. is divided into implicit and display cursors.
⑴ implicit cursors: All DML statements are implicit cursors, and SQL statement information can be obtained through implicit cursor properties.
⑵ Display cursors: The user displays the declared cursor, which specifies the result set. An explicit cursor is required when the query returns more than one row.
②REF cursor: A temporary object that dynamically associates the result set.

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.