Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parsing string into a SQL statement
Message
From
22/12/2008 14:17:03
 
 
To
22/12/2008 12:16:17
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01369199
Message ID:
01369232
Views:
8
>Trying to build SQL from a RowSource. I want to turn this:
>
>vNewVal = "Race.RaceCode, RaceDesc"
>
>Into this:
>
>"SELECT RaceCode AS F1, RaceDesc AS F2 FROM Race"
>
You might also look at.......
FUNCTION sqlParse
LPARAMETERS vNewVal

**vNewVal = "Race.RaceCode, RaceDesc"
**  Assumes first phrase has the table name.field
**  Assumes remaining phrases are just fields
LOCAL lcSql, I

lcSQL = ""

FOR I = 2 TO GETWORDCOUNT(vNewVal,".,")
	lcSql = lcSql + ", " + GETWORDNUM(vNewVal,I,".,") + " AS F" + TRANSFORM(I-1)
ENDFOR

RETURN "SELECT " + SUBSTR(lcSql,2) + " FROM " + GETWORDNUM(vNewVal,1,",.")
Previous
Reply
Map
View

Click here to load this message in the networking platform