Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Moving a record pointer.
Message
De
10/10/2000 11:34:00
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00427244
Message ID:
00427323
Vues:
13
Do I understand you right that the only way to position a record pointer is then by doing a WHILE loop?

>You could pass in a key to start from and add a WHERE clause that gets everything greater than or equal to the passed in ID. If you don't pass anything in, retrieve all records.
>
>HTH.
>
>>I have created the following Stored procedure:
>>
>>
>>CREATE PROCEDURE [omcountry_moveto] @lcAction CHAR(10), @lcCurIdKey
>> UNIQUEIDENTIFIER, @lcNewIdKey UNIQUEIDENTIFIER OUTPUT AS
>>DECLARE omcountry_cursor CURSOR SCROLL FOR SELECT idkey FROM omcountry ORDER BY code
>>OPEN omcountry_cursor
>>IF (@lcAction = 'TOP')
>>BEGIN
>>	FETCH FIRST FROM omcountry_cursor INTO @lcNewIdKey
>>END
>>IF (@lcAction ='BOTTOM')
>>BEGIN
>>	FETCH LAST FROM omcountry_cursor INTO @lcNewIdKey
>>END
>>IF (@lcAction = 'NEXT')
>>BEGIN
>>	FETCH NEXT FROM omcountry_cursor INTO @lcNewIdKey
>>END
>>IF (@lcAction = 'PREV')
>>BEGIN
>>	FETCH PRIOR FROM omcountry_cursor INTO @lcNewIdKey
>>END
>>CLOSE omcountry_cursor
>>DEALLOCATE omcountry_cursor
>>
>>The top and button part works fine. But how do I do with NEXT and PREV? I must first stand in the right position before I can do the FETCH command and how do I do that in the best way? I hope a WHILE loop with repeated FETCH NEXT is not the only way to walk...
---( Mårten Törnquist )---
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform