Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Increment Field
Message
From
11/04/2008 15:41:07
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01309981
Message ID:
01310047
Views:
26
>>Is there a way to have a value that increments by one in a SQL statement?
>>
>>
>>SELECT *, IncrementThisValueByOne FROM MyTable
>>
>>
>>To get:
>>
>>
>>MyFieldOne MyFieldTwo IncrementThisValueByOne
>>
>>Bobby      Jones      1
>>Jamie      Lee        2
>>Terry      Hatcher    3
>>
>
>Yes.
>
>select MyField1, myField2, recno() from (select myField1, myField2 from myTable...)
>
>That was a tip by Tamar Granor on the last NY User Group meeting.

Did Tamar show this exact code for this exact purpose? Is the use of RECNO() in SELECT - SQL guaranteed to work in this manner in VFP9?

In earlier versions of VFP I got burned with some very hard-to-track bugs when using RECNO() in SELECTs. There were significant SQL engine enhancements in VFP9; maybe it's now safe to use it that way. However, VFP9 also supports more complex queries in general, and without a lot of testing, how can we be assured that RECNO() will work as expected in these scenarios?

Another consideration is that using RECNO() in a query is not ANSI-compliant. So, you couldn't use it to pull data off a non-VFP backend.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform