>>>>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)
Whats wrong with
lcString = ''
for x = 1 to 10
lcString = m.lcString+ "," + "a"
endfor
lcString = SUBSTR(m.lcString,2)
?
Just a clear simple command.
Works even with the empty string ...
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]