Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
cheriansabs
Starting Member
2 Posts |
Posted - 2006-08-08 : 08:57:00
|
hi people,i have registered recently on this forum.I got a basic doubt bout cursorsThis is my cursor contained inside stored procedureDECLARE GetSQL_Cursor CURSORFORSELECT 'T'+ Ltrim(str(idx)),value FROM dbo.fn_Split(@responseMsg1,@sDelim) ORDER BY idxOPEN GetSQL_CursorWHILE @@Fetch_Status = 0begin FETCH NEXT FROM GetSQL_Cursor INTO @alias, @value if convert(int,@value)>=20 and convert(int,@value)<30 begin break endendwhen i run this code using sql Query analyser it wks without any problemsbut when i run this stored procedure using asp.net code it does not enter the while loop.any clues why.thanks in advance |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-08-08 : 12:44:50
|
Can you explain what you are trying to do?There can be better method than what you are trying.Post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
cheriansabs
Starting Member
2 Posts |
Posted - 2006-08-09 : 02:40:09
|
hi madhav,I did find a way out of this problem.Instead of using @@fetchstatus.I found out the maximum no of records my function split was returning.and then i ran a loop against a counter.the whole problem is with @@fetchstatus.It is a global varable for all connections.so once my loop was over it set @@fetchstatus=-1so when i tried running the loop thru asp.net it found out tht @@fetchstatus=-1 and then would enter the while loop.I hope this helps out anybody with a similar probthank you guys |
 |
|
rob_farley
Yak Posting Veteran
64 Posts |
Posted - 2006-08-09 : 04:10:27
|
Why don't you do a fetch after opening it, before checking @@fetch_status?The standard thing for cursors is:declareopenfetchwhile @@fetch_status = 0begin do_stuff fetchendclosedeallocateJust seems to me you've missed some bits...Rob Farleyhttp://robfarley.blogspot.com |
 |
|
|
|
|