Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor from table based on value
Message
From
13/04/2003 10:43:30
 
 
To
13/04/2003 09:15:25
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00777023
Message ID:
00777025
Views:
10
Chaim,
Try this:
CREATE CURSOR NewCursor (nFrom i, nTo i)

SELECT YourTable
SET ORDER TO nId
GO TOP

*-- initialize memvars
lnFrom     = nId
lnPrevious = lnFrom-1

SCAN
   
   IF NOT nId = lnPrevious+1
      *-- missing Id
      *-- add record and reset memvar
      INSERT INTO NewCursor VALUES(lnFrom, lnPrevious)
      lnFrom = nId
   ENDIF
   *-- save current Id for next comparison
   lnPrevious = nId
   
ENDSCAN

*-- add another record to cover last record
INSERT INTO NewCursor VALUES(lnFrom, lnPrevious)
HTH
>Who can help me with the following task?
>I have a table with ordered Ids while some ids are missing(For example: 1,2,3,4,5,7,8,9,10,11,14,15…).
>I need it into cursor with the following structure:
>The cursor will include two columns:
>1. from, 2. to.
>Based on the following concept:
>If the next number in the table source >1 from the previous, the cursor will hold it other line (in the previous example, this will be the cursor lines:
>From 1 to 5
>From 7 to 11
>From 14 to 15).
>It's very important for me.
>Thanks for help
>Chaim
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform