SELECT LocGarment INDEX ON kLoc + kGarment TAG LocGarment select G.cStyle, G.kGarment, G.cDescrip, G.nDefPrice, ; iif(INDEXSEEK (lkLoc + G.kGarment, .F., "LocGarment", "LocGarment"), "L", "X") as cType ; from Garments GB) USE a UDF:
select G.cStyle, G.kGarment, G.cDescrip, G.nDefPrice, ; GetType () as cType ; from Garments G FUNCTION GetType *-- Return the type here ENDFUNCC) Fill out the cursor after the query:
select G.cStyle, G.kGarment, G.cDescrip, G.nDefPrice, " " as cType; from Garments G; INTO CURSOR curTemp READWRITE SCAN SELECT LocGarment LOCATE FOR (LocGarment.kLoc == lkLoc) AND (LocGarment.kGarment = curTemp.kGarment) SELECT curTemp REPLACE cType WITH IIF (FOUND ("LocGarment"), "L", "X") ENDSCAN>Ok, let me think about getting the G. out. I still need a select though in my "real" code, rather than replacing the select with joins. The version that I offered was done to make the select easy to see (and generate an error).
>select G.cStyle, G.kGarment, G.cDescrip, G.nDefPrice, ; > iif(lkLoc in ; > (select LG.kLoc from LocGarment LG where LG.kGarment = G.kGarment), ; > "L", "X") as cType ; > from Garments G >>... the error message is just that it needs a comma (I think that it's parsing the real error message and reporting on it). What I'm trying to do is to add and populate a calculated field (cType) so the subselect is located in the field list. I pulled it out just to see if being in the field list was the problem.