Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select VFP vs SQL Server
Message
 
 
To
16/09/2014 09:08:56
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01607580
Message ID:
01607620
Views:
70
>>>>Hi,
>>>>
>>>>I ran into the following, fairly small, issue. I use Stonefield Query (older version) which returns the following expression (when you select one of several):
>>>>
>>>>
>>>>SELECT * FROM MyTable WHERE (inlist(upper(MyTable.MyField),'TEST1','TEST2',))
>>>>
>>>>
>>>>Note that trailing comma, after ('TEST2'). When I execute this expression against VFP database I get error. When I execute this SQL Select against SQL Server, no error.
>>>>
>>>>Does it mean that SQL Server ignores the trailing comma? Or there is another reason for difference for this behavior between VFP and SQL?
>>>
>>>Hi, Dmitry,
>>>
>>>First, the SQL database engine doesn't have INLIST. Just IN.
>>>
>>>This works:
>>>select * from Production.product where productid in (1,2,3)
>>>
>>>This doesn't:
>>>select * from Production.product where productid in (1,2,3,)
>>
>>Kevin,
>>
>>You are correct. SF Query uses IN where for VFP it uses INLIST. And when it uses IN (for SQL Server) it does not leave trailing comma. So it must be a small bug in their software. Since I have the source code I will have to "dig into" and find where to make sure that the trailing comma for VFP has to be "deleted" or not "added"
>>Thank you.
>
>That is another reason I always concatenate the comma without any conditional checks and then delete the one trailing comma afterward. Firing a conditional check for each loop is not efficient in the long run.
>
>for x = 1 to 10
> lcString = m.lnString + "a" + ","
>endfor
>lcString = left(m.lcString,len(m.lcString)-1)

The code that leaves the trailing comma is not mine. But I am sure I will find the places where I need to "clean up" and the problem will be resolved.
Thank you
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform