Home » SQL & PL/SQL » SQL & PL/SQL » cursor fetching (Oracle 10G AIX)
cursor fetching [message #340318] Tue, 12 August 2008 05:32 Go to next message
krishnapooranitt
Messages: 3
Registered: August 2008
Location: chennai
Junior Member
Hi
Cursor fetching problem in 10g
When the cursor is fetching the records from table, it have to select the first record among duplicates and then have to reject the remaining records.
For Ex:
Name Class Marks
a EEE 97
a EEE 98
a EEE 99

Eliminating the duplicates based on name and class.
So my cursor should fetch the first record
a EEE 97 and the remaing records should get reject.
But when iam executing the procedure first time it fetching the first record and rejecting the second and third records.
But in the subsequent executions it is fetching the records randomly.
Wats the problem in this.
Can anyone please help on this.
Regards
Suganthi
Re: cursor fetching [message #340322 is a reply to message #340318] Tue, 12 August 2008 05:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
But in the subsequent executions it is fetching the records randomly.
Wats the problem in this.

You didn't order the rows.

By the way, don't use a cursor for this, have a look at ROW_NUMBER, RANK and DENSE_RANK functions.

Regards
Michel
Re: cursor fetching [message #340323 is a reply to message #340318] Tue, 12 August 2008 05:43 Go to previous message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Or, if possible, a simple MIN function, such as
SELECT name, class, MIN(marks)
FROM this_table
GROUP BY name, class
Previous Topic: Check for empty and null
Next Topic: Is it possible to call a function in SQL which calls a procedure doing inserts?
Goto Forum:
  


Current Time: Wed Dec 07 02:58:06 CST 2016

Total time taken to generate the page: 0.05581 seconds