Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning an Incremental Field Value in SQL
Message
 
To
30/04/2004 09:07:17
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00899694
Message ID:
00899717
Views:
18
This message has been marked as the solution to the initial question of the thread.
Try this:

sele ... group by ... into cursor yy readwrite
repl all uniqueid with recn()

>That worked great, except (and I should have had this in my posted SQL)...
>
>I'm also using a GROUP BY clause which then causes all the UniqueID values to be the same.
>
>>Try this:
>>
>>....
>>   RECNO() AS UniqueID ;
>>....
>>
>>
>>>I'm trying to return 1 for the value of the UniqueID field in the first record and then increment each subsequent record in MyCursor. The SQL below returns all "1" in the resulting records. I'm sure this is because the pointer does not move in MyTable, but there must be a simple way. I was lookng at AutoInc, but that doesn't seem to be applicable to cursors. We have a GetNext functionality for tables but I don't need it here. I'm sure it's simple, but it's not coming to me right now.
>>>
>>>
>>>SELECT ;
>>>   MyTable.Field1, ;
>>>   RECNO('MyTable') AS UniqueID ;
>>>   FROM MyTable ;
>>>   INTO CURSOR MyCursor
>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform