Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,615 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 988 people online right now. Registration is fast and FREE... Join Now!




Cursor

 
Reply to this topicStart new topic

Cursor

rahul_b87
post 16 Jul, 2008 - 09:36 PM
Post #1


New D.I.C Head

*
Joined: 16 Jul, 2008
Posts: 2

Hi all
What is the role of cursor? why we use it ? There are any alternate of cursor.if it is then what is the diff ?
User is offlineProfile CardPM

Go to the top of the page

lordms12
post 17 Jul, 2008 - 06:04 AM
Post #2


D.I.C Regular

Group Icon
Joined: 16 Feb, 2008
Posts: 312



Thanked 13 times

Dream Kudos: 225
My Contributions


Cursor is called iterator in many other programming languages.
It is like loops.

Simple code use for loop:
pl/sql
FOR RecordIndex IN (SELECT person_code FROM people_table)
LOOP
DBMS_OUTPUT.PUT_LINE(RecordIndex.person_code);
END LOOP;


Same code using cursor:
pl/sql
DECLARE
CURSOR cursor_person IS
SELECT person_code FROM people_table;
BEGIN
FOR RecordIndex IN cursor_person
LOOP
DBMS_OUTPUT.PUT_LINE(RecordIndex.person_code);
END LOOP;
END;


For more infos check links:
http://en.wikipedia.org/wiki/Cursor_%28databases%29
http://www.sqlteam.com/article/cursors-an-overview
http://en.wikipedia.org/wiki/SQL_Problems_Requiring_Cursors
http://en.wikipedia.org/wiki/PL/SQL#Cursor_FOR_loops
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:59AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month