Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why would @@FETCH_STATUS return -2
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01094578
Message ID:
01094596
Vues:
1952
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
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform