Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I run a SQL statement that includes variables

Status
Not open for further replies.

rpp

Programmer
Feb 28, 2002
32
0
0
US
I am trying to select a record set that has a variable used where field names are normally listed., Why wont this work and what might be the best work around?


lcSort = ''
IF Thisform.lstsorted.listcount >= 1
FOR lnCount = 1 TO (Thisform.lstsorted.listcount)
lcItem = Thisform.lstsorted.listitem(lnCount)
IF (lnCount) = 1
lcSort = 'ALLTRIM('+lcItem+')'
ELSE
lcSort = lcSort + ' + ' + 'ALLTRIM('+lcItem+')'
ENDIF
ENDFOR
ENDIF


select * from (infile) where city = 'Palm Bay' or city = 'Malabar' or city = 'Valk' ;
ORDER BY (lcsort)


Thanks in advance
 
You need to use a "&" to indicate the variable substitution: ORDER BY (&lcsort)

Brian
 
Man your the greatest!!!!

I have worked around that thing for years.

Thank you so much!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top