Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    16

    Unanswered: using distinct function within a cursor

    I am attempting to use the distinct function within a cursor but for some reason, the cursor is not populating distinct results. I think the problem may possible be that the cursor is not declared in the beginning. Its an implicit cursor. Here is the code:


    For i IN (Select item1, item2, item3 from table1)
    For j IN (Select distinct item4 from table2)

    ..........................
    ..........................
    ..........................

    END LOOP;
    END LOOP;




    For some reason, the nested fro loop select statement does not pick up distinct item4 values. Any ideas on what may be ocurring?
    Jason B. Simms

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: using distinct function within a cursor

    There is nothing apparently wrong with the code above. DISTINCT means DISTINCT wherever you use it. If item4 is a DATE column then there may be a time component that you are not seeing?

  3. #3
    Join Date
    Jan 2004
    Posts
    37
    and if it is date then use trunc function to get rid of the time component


    select distinct(trunc(item4) ) from .....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •