Return from a cursor with resome

  • My application is in classic ASP and I need to process the return from a cursor fetch-by-fetch.

    Cursor values are returned by a stored procedure. I can put in a temp table and process.

    Is there a better way? I want something like this:

    DECLARE mycursor

    Open mycursor

    While (@@fetch_status = 0)

    BEGIN

    Fetch Next from mycussor

    -- some processing /select etc

    Return from mycursor with RESUME

    Fetch Next

    END

    Close mycursor

  • what is the some processing select stuff?

    Depending on what it is you may not need a cursor

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • The inner processing is a select with conditions.

    Is this possible..

  • It may be possible to do this without a cursor,

    If you post your code , table structres and sample data then I am sure you will get a more complete answer.

  • That is a good suggestion. I converted the inner select/processing to a function and am calling this function in my select statement: no cursor required

  • You may have eliminated the cursor, but you may not have eliminated the RBAR (Modenism for Row By Agonizing Row) processing.

    If you post your code, table DDL (create statements), sample data (as insert statements), and expected results; we may be able to find a more effective way to complete the required processing.

    Read the article in my signature block for more info on how to best help us help you.

  • chandrika5 (11/10/2008)


    That is a good suggestion. I converted the inner select/processing to a function and am calling this function in my select statement: no cursor required

    As Lynn stated, you've probably replaced one form of RBAR with another. There's a lot of ways to get around that, but we at least need to see the real code. His instructions for the rest would be even better because we could actually give you a tested example.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply