Common Oracle cursor attributes

Source: Internet
Author: User

Oracle cursor is familiar to everyone. The following describes common attributes of Oracle cursor in detail. If you are interested in Oracle cursor, take a look.

Common Oracle cursor attributes:

% FOUND: When the variable finally obtains the record from the cursor, the record is FOUND in the result set.

% NOTFOUND: When the variable finally retrieves records from the cursor, no records are found in the result set.

% ROWCOUNT: number of records that have been obtained from the cursor at the current time.

% ISOPEN: whether or not to open.

 
 
  1. Declare
  2.  
  3. /* Define a static cursor */
  4.  
  5. Cursor emps is
  6.  
  7. Select * from employees where rownum <6 order by 1;
  8.  
  9. Emp employees % rowtype;
  10.  
  11. Row number: = 1;
  12.  
  13. Begin
  14.  
  15. Open emps;/* Open static cursor */
  16.  
  17. Fetch emps into emp;/* read the current row of the cursor */
  18.  
  19. Loop
  20.  
  21. If emps % found then
  22.  
  23. Dbms_output.put_line ('looping over record '| row |' of '| emps % rowcount );
  24.  
  25. Fetch emps into emp;
  26.  
  27. Row: = row + 1;
  28.  
  29. Elsif emps % notfound then
  30.  
  31. Exit;
  32.  
  33. End if;
  34.  
  35. End loop;
  36.  
  37. If emps % isopen then
  38.  
  39. Close emps;/* Close the cursor */
  40.  
  41. End if;
  42.  
  43. End;
  44.  
  45. /
  46.  


 


Edit recommendations]

Create tables and indexes in Oracle

How to Implement Oracle index Reconstruction

Complete Oracle File System Parsing

How to query the current Oracle system time

ORACLE system table and data dictionary View

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.