Connecting Tech Pros Worldwide Forums | Help | Site Map

Cursor that is supposed to return one value Returns duplicated values of same row

Newbie
 
Join Date: Dec 2008
Posts: 9
#1: Dec 14 '08
I have a cursor inside a program unit in Oracle Forms 6
and its supposed to get one row from this cursor ..
but in some values (only some and others not) it gets the same row twice (duplicated) in cursor's active set , I have checked on ROWNUM and it confirmed same row retrieval !!

I checked the table for duplicated values but it returned non , also the selected column is the primary key !!!!

DECLARE
CURSOR C IS
SELECT CRIME.CRIME_CODE
FROM CRIMES CRIME
WHERE yy=:yy
AND xx=:xx ;

BEGIN
OPEN C ;
FETCH C --
INTO number_type_variable ;

Close C;

Note that :
yy column contains ARABIC language data


I have solved the problem with some workaround , BUT I need to understand why this behaviour occurs ...

any one faced such problem before ??

Member
 
Join Date: Oct 2008
Location: Home
Posts: 127
#2: Dec 14 '08

re: Cursor that is supposed to return one value Returns duplicated values of same row


Hi,

Is this the exact code you are using? If not, then please post the exact code, otherwise it is just everyone's guess, cause there are a lot of things that can go wrong. If it is the exact code, I can't think of a reason why Oracle would return the same key twice (If it is returning the primary key)

Pilgrim.
Newbie
 
Join Date: Oct 2008
Posts: 27
#3: Jan 11 '09

re: Cursor that is supposed to return one value Returns duplicated values of same row


Try using DISTINCT with select like:

SELECT DISTINCT CRIME.CRIME_CODE
FROM CRIMES CRIME
WHERE yy=:yy
AND xx=:xx ;
Newbie
 
Join Date: Dec 2008
Posts: 9
#4: Jan 11 '09

re: Cursor that is supposed to return one value Returns duplicated values of same row


Quote:

Originally Posted by Jibran View Post

Try using DISTINCT with select like:

SELECT DISTINCT CRIME.CRIME_CODE
FROM CRIMES CRIME
WHERE yy=:yy
AND xx=:xx ;

I had already done so ... same thing happens :)
N.B. crime_code is the table's primary key :D
Familiar Sight
 
Join Date: Apr 2008
Posts: 149
#5: Jan 14 '09

re: Cursor that is supposed to return one value Returns duplicated values of same row


Quote:

Originally Posted by asp2 View Post

I had already done so ... same thing happens :)
N.B. crime_code is the table's primary key :D


Hi,

I wonder "How there can be duplicate data in the table with the same primary Key ?"

There might be some manual mistake .Please remove that redundant data n your problem will be solved. :)

Thanks!
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#6: Jan 15 '09

re: Cursor that is supposed to return one value Returns duplicated values of same row


Do some analysis by running your query in SQLPLUS and check why the duplicates are coming. Good that you have solved the problem. I ncase if you have made any change in your query or code then Do post the exact solution here that would help peoples around with the same problem.
THanks
Newbie
 
Join Date: Dec 2008
Posts: 9
#7: Jan 26 '09

re: Cursor that is supposed to return one value Returns duplicated values of same row


I haven't solved the problem I have overcomed it , by handing errors with :

cursor%NOTFOUND and sqlcode <> 0
Reply

Tags
active set, duplicated row, fetch, forms