Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Red face Unanswered: complex query - cursors

    Is there a way to compare cursors. Basically, i have cursors with number of records only know at runtime. I would like to compare them and get the common result.
    Basically the cursors are filled by a query. Are cursors the way to go or not. Should i use something else? I need to get some results out of tables and compare them to get the common results.
    Help will be highly appreciated!
    Thanks!

  2. #2
    Join Date
    Feb 2004
    Posts
    3
    You can do programmatically in pl/sql. if you have a common column that is indexed in both the tables, open two cursors for two tables including the common index column. Now loop through both the cursors together and check for common rows. If you only want the common rows, you can always do the join on the tables and write as one query.

    Vijaya

  3. #3
    Join Date
    Oct 2003
    Posts
    87
    Originally posted by Vijaya K
    You can do programmatically in pl/sql. if you have a common column that is indexed in both the tables, open two cursors for two tables including the common index column. Now loop through both the cursors together and check for common rows. If you only want the common rows, you can always do the join on the tables and write as one query.

    Vijaya
    Yes, but make sure to use the same ORDER BY on both cursors . . .
    Oracle - DB2 - MS Access -

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

    Re: complex query - cursors

    Why not build one cursor with a query that compares the 2 sets of data?

  5. #5
    Join Date
    Feb 2004
    Posts
    18

    Re: complex query - cursors

    Originally posted by djdev
    Is there a way to compare cursors. Basically, i have cursors with number of records only know at runtime. I would like to compare them and get the common result.
    Basically the cursors are filled by a query. Are cursors the way to go or not. Should i use something else? I need to get some results out of tables and compare them to get the common results.
    Help will be highly appreciated!
    Thanks!
    If the same columns are extracted in both the cursors then I think you can write a single cursor with both the intersection of both the select statements like
    SELECT .....
    INTERSECT
    SELECT ....

    I hope this solves your problem

Posting Permissions

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