Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    34

    Unhappy Unanswered: check if cursor exists

    I declare a cusror named crInv inside a loop.
    Since I open this cursor a lot of times I want to check if is already opened.
    I try to use the Cursor_status function but it always returns -3.
    The syntax is:

    DECLARE crInv SCROL CURSOR FOR
    SELECT Val1, Val2 FROM TABLE1 WHERE Val3=450

    If Cursor_Status('local','crInv')>0 BEGIN
    CLOSE crInv
    DEALLOCATE crInv
    END

    This code is inside a loop.
    If I PRINT Cursor_Status('local','crInv') before and after the DECLARE statement it always returns -3.
    What is wrong??

    Best regards,
    Manolis

  2. #2
    Join Date
    Nov 2003
    Posts
    94
    DECLARE crInv LOCAL SCROLL CURSOR FOR ...

    The typical default for a cursor is GLOBAL

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Sounds like an extremely expensive process...

    Ever think about a set based process?

    Can you post the "Loop" code?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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