Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why would @@FETCH_STATUS return -2
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01094578
Message ID:
01094596
Views:
1959
In this case the cursor is not updated in any of the sub procedures.

>From DECLARE CURSOR in BOL:
>
>"If a row is deleted, an attempt to fetch the row returns an @@FETCH_STATUS of -2. Updates of key values from outside the cursor resemble a delete of the old row followed by an insert of the new row. The row with the new values is not visible, and attempts to fetch the row with the old values return an @@FETCH_STATUS of -2."
>
>
>
>>Periodically @@FETCH_STATUS returns a -2. What could be causing this problem? This procedure calls Proc2 inside the loop."
>>
>>
>>declare
>>@Ctr			int,
>>@stor_id		int
>>
>>Set @ctr = 1
>>
>>declare Temp1 cursor scroll
>>	for 	
>>		select
>>			stor_id
>>		from stores with (nolock)
>>
>>open Temp1
>>
>>FETCH ABSOLUTE @Ctr FROM Temp1 INTO @stor_id
>>
>>WHILE @@FETCH_STATUS = 0
>>	BEGIN
>>	
>>		EXEC Proc2
>>
>>		set @ctr = @Ctr + 1
>>
>>		FETCH ABSOLUTE @Ctr FROM Temp1 INTO @stor_id
>>		print '---------------------------------'
>>		print 'sp1 ' + convert(char,@ctr)+convert(char,@@FETCH_STATUS)
>>	END
>>
>>CLOSE Temp1
>>DEALLOCATE Temp1
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform