Opening cursor after closing does not seem to requery
From: mberry (lionheart1159_at_yahoo.com)
Date: 03/12/04
- Next message: EDAK: "Re: UDF/SP Editor"
- Previous message: Brian Henry: "Re: getting values from inserted table"
- Next in thread: David Portas: "Re: Opening cursor after closing does not seem to requery"
- Reply: David Portas: "Re: Opening cursor after closing does not seem to requery"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 12 Mar 2004 11:22:12 -0500
Okay, I'm a newbie, so any help would be appreciated.
I declare a cursor, then enter a loop. Inside the loop, I open and fetch,
and everything works wonderfully until I close the cursor. When I re-open
the cursor (I do this because I want it to re-query per the declaration), it
opens at the same row as the initial opening, even though the variable in
the query part of the cusor declaration has clearly changed.
Declare myCursor Cursor
For Select col1_name
, col2_name
, col3_name
From myTable
Where col3 = @other_var
Order By col1_name DESC
For Update of col2_name
While (@@FETCH_STATUS = 0)
Begin
Open myCursor
Fetch myCursor Into @col1_var, @col2_var, @col3_var
While (@@FETCH_STATUS = 0)
Begin
parse through the table, doing stuff that could probably be done
easier with correlated subqueries
eventually, change @other_var
End
close myCursor
End
After I close myCursor, and re-open it at the top of the loop, I think it
should open pointing to the row that is qualified by the new value of
@other_var, but it does not. I'm sure I am doing something wrong. I have
succeeded by deallocating the cursor, and moving the myCursor declaraton
inside the loop, but this seems to be very inefficient.
Thanks in advance for any help!
Michael
- Next message: EDAK: "Re: UDF/SP Editor"
- Previous message: Brian Henry: "Re: getting values from inserted table"
- Next in thread: David Portas: "Re: Opening cursor after closing does not seem to requery"
- Reply: David Portas: "Re: Opening cursor after closing does not seem to requery"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|