Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hard to explain - Building SQL
Message
 
 
To
14/01/2009 17:10:24
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01373759
Message ID:
01373772
Views:
14
Just add an extra variable called lcAdditionalFields, set it to appropriate value starting with , and then build your SQL using lcFields + lcAdditionalFields.

BTW, I prefer TEXT ENDTEXT method here instead.

>I'm using this in a report, works great except that there are fields on the report that may not be in the SQL results. I need to be able to include this in the SQL if the number of records (m.ix or lnReportColumnCount) is only 4:
>
>" ' ' AS Fld5, ' ' AS Fld6, ' ' AS Fld7, ' ' AS Fld8"
>
>But this if the number of records is 6:
>
>" ' ' AS Fld7, ' ' AS Fld8"
>
>This is a section of the block of code:
>
>	m.ix = 0
>	SCAN
>		m.ix = m.ix + 1
>		lcFields = lcFields + IIF(m.ix > 1, ', ','') + ALLTRIM(FieldName) + ' AS Fld'+TRANSFORM(ix)
>	ENDSCAN
>	lnReportColumnCount = m.ix
>	RunSQL = 'SELECT ' + lcFields + ' FROM ' + lcTable + ' ORDER BY ' + lcOrderField + ' INTO CURSOR ReportCursor'
>	&RunSQL
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform