Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameterized SQL PassThrough Question
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00329981
Message ID:
00330003
Views:
45
>Can anyone tell me why the first SQL statement returns 17 records and the second returns none? Both SQLEXEC()'s return 1 so there are no errors in either SELECT.
>
>
>? SQLEXEC(1,"SELECT *;
> FROM ZAKI.PROJ Proj;
> WHERE {fn LEFT(Proj.PROJ_ID,6)} IN ('000609','000172','001113') AND {fn LENGTH(Proj.PROJ_ID)}=10;
> ORDER BY Proj.PROJ_ID")
>
>mcproj="'000609','000172','001113'"
>
>? mcproj
>? SQLEXEC(1,"SELECT *;
> FROM ZAKI.PROJ Proj;
> WHERE {fn LEFT(Proj.PROJ_ID,6)} IN (?mcproj) AND {fn LENGTH(Proj.PROJ_ID)}=10;
> ORDER BY Proj.PROJ_ID")
>
This is a know problem [at least by me] that you can not parameterize an IN() clause. If your mcProg parameter just has 1 values in it, it will work. The problem is in having to have quotes around each value. There is no way to just pass '000609','000172','001113' without addition surrounding double-quotes. Now if you do not predefine the value of mcProj, and let VFP prompt you for the list, it will work with more than 1 value.

The only way to get it to work with variables, is to build the list of values:
cSQL = "......." ;
         + "where .... IN ('" + mcProg1 + "', '" + mcProg2 + "') ..."
I believe, IN (&mcProg.) will also work.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform