Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving a record pointer.
Message
From
10/10/2000 11:34:00
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00427244
Message ID:
00427323
Views:
15
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 )---
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform