Total Pageviews

February 6, 2015

2/06/2015 09:45:00 AM



Why do we need the Cursors?
• SELECT statement should return only one row at a time in previous PL/SQL programs. This is too restrictive in many applications.
• We use the idea of Cursor to handle the above problem. Cursor is the mechanism that allows the program to step through the rows one at a time.
 Cursor contains two parts
  •  Header
  •  Body
Header includes cursor name, any parameters and the type of data being loaded.
Body includes the select statement.
Ex:
Cursor c(dno in number) return dept%rowtype is select *from dept;
           In the above
                        Header – cursor c (dno in number) return dept%rowtype
                        Body – select *from dept

CURSOR TYPES
  • Implicit (SQL)
  • Explicit
  • Parameterized cursors
  • REF cursors
CURSOR STAGES
  • Open
  • Fetch
  • Close
CCURSOR ATTRIBUTES
  • %found
  • %notfound
  • %rowcount
  • %isopen
  • %bulk_rowcount
  • %bulk_exceptions
CURSOR DECLERATION
Syntax:
     Cursor <cursor_name> is select statement;
Ex:
     Cursor c is select *from dept;


 
Related Posts Plugin for WordPress, Blogger...