Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links


Cursor in oracle database

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-02-2010
Member
 
Join Date: Nov 2009
Posts: 39
Cursor in oracle database

Sponsored Links
Hello sir,

I have taken an option in the oracle database course the DBA option. This option is not so related to developing application.The DBA is not responsible for these thing it's the task of development team.But I need to know few things about the CURSOR concept in oracle database.At some points, The DBA also need to know but not necessary. So please let me know about the cursor in database.

Thanks.

Reply With Quote
  #2  
Old 11-02-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,507
Cursor in oracle database

Cursor in oracle database :

To execute the SQL statement,some reserve area is allocated .The PL/SQL allows you for naming. A cursor in the context area acts as a handle or pointer. The PL/SQL program are designed to control over the context area using Cursor. Cursor shows a structure in the memory and is slightly unique from cursor variable.

During the creation and declaration of a cursor,a pointer variable is assigned to you,which doesn't point for any object.When the cursor is being opened the memory is assigned and the cursor structure is created.Then after cursor variable points to the cursor.
Reply With Quote
  #3  
Old 11-02-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,839
Implicit cursors in oracle database

The implicit cursors :

The declaration of implicit cursors performed during SQL queries returning single row from the PL/SQL block.The implicit cursors are constructed through the simple SELECT statements which resides between the BEGIN and END section of PL/SQL Block.It is easy to perform the code.

The cursor are capable to retrieve exactly one row at a time.The commonly occurred exceptions regarding the implicit cursor areNO_DATA_FOUND or TOO_MANY_ROWS. The syntax would be as follows :

Code:
SQL> SELECT emp_name, salary  INTO Enm, Esal FROM EMP WHERE EMPNO = 4439;
Where the Emp_name and salary are columns of the EMP table and Enm and Esal are variables being used to store the result fetched by the query.

Last edited by MindSpace : 11-02-2010 at 04:36 PM.
Reply With Quote
  #4  
Old 11-02-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,371
Explicit Cursors in oracle database

Explicit Cursors :

The explicit cursor are used when a query capable to return more than one rows for a query.A set of rows is fetched by the query is treated as active set.The space occupied by the active set is dependent on search criteria defined by SELECT statement.

The syntax would be as follows :

CURSOR <cursor-name> IS <select statement>

And the sample code to construct the Explicit Cursor would be as explained below:

Code:
DECLARE
CURSOR e_cursor IS SELECT emp_name FROM EMPLOYEE;
BEGIN
----
---
END;
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 11-02-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,382
Attributes of Explicit Cursor in oracle database

Attributes of Explicit Cursor :

The Cursor defined by the user has at least four attributes.There are some useful attributes are being used to define and investigating on cursor.The attributes are explained below :
  • %NOTFOUND - Its follow the Boolean attribute in true or false,when there are no rows left in the cursor to fetch it activates.
  • %FOUND - It activates the Boolean variable and evaluates to true if the last fetch comes succeeded.
  • %ROWCOUNT - It’s a numeric attribute and counts the number of rows which is fetched by the cursor earlier.
  • %ISOPEN - which is a boolean variable and shows the status of the cursor.
Reply With Quote
  #6  
Old 11-02-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,278
Using Cursor For Loop in oracle database

Using Cursor For Loop :

It is being used to process multiple records. there are 2 benefits with this type of cursor.

1 - It implicitly declares a %ROWTYPE variable and implement it as LOOP index.
2- It performs the opening and closing automatically when records are being fetched and closes when fetching comes to complete.

Code:
SQL> Declare 
       Cursor cur1 IS select Emp_name,salary from EMP;
BEGIN 
For emp_rec IN cur1 
LOOP
DBMS_OUTPUT.PUT_LINE(emp_rec.emp_name||' ' ||emp_rec.salary);
END LOOP;
END;
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Cursor in oracle database"
Thread Thread Starter Forum Replies Last Post
Joins in oracle database Adriana_andros Software Development 5 11-02-2010 07:53 PM
Subqueries in oracle database Landan Software Development 4 09-02-2010 04:57 PM
Different processes in oracle database Aileen_L Software Development 4 01-02-2010 03:38 PM
Packages in oracle database Garlands Software Development 3 30-01-2010 01:55 PM
Oracle Announces TimesTen In-Memory Database 11g and In-Memory Database Cache 11g prakashseth Web News & Trends 1 30-07-2009 04:58 PM


All times are GMT +5.5. The time now is 09:26 PM.