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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asp2
    New Member
    • Dec 2008
    • 10

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

    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_COD E
    FROM CRIMES CRIME
    WHERE yy=:yy
    AND xx=:xx ;

    BEGIN
    OPEN C ;
    FETCH C --
    INTO number_type_var iable ;

    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 ??
  • Pilgrim333
    New Member
    • Oct 2008
    • 127

    #2
    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.

    Comment

    • Jibran
      New Member
      • Oct 2008
      • 30

      #3
      Try using DISTINCT with select like:

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

      Comment

      • asp2
        New Member
        • Dec 2008
        • 10

        #4
        Originally posted by Jibran
        Try using DISTINCT with select like:

        SELECT DISTINCT CRIME.CRIME_COD E
        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

        Comment

        • madankarmukta
          Contributor
          • Apr 2008
          • 308

          #5
          Originally posted by asp2
          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!

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            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

            Comment

            • asp2
              New Member
              • Dec 2008
              • 10

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

              cursor%NOTFOUND and sqlcode <> 0

              Comment

              Working...