Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SPT Syntax
Message
 
 
To
13/11/2008 12:13:35
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01361709
Message ID:
01361710
Views:
19
>this is my SPT string. My trouble is some querys have more than one opstc with a value of say 20. I would like to get the one with the largest opseq when that happens. Both of these fields are in the amflib6.morout table.
>
>
>pdm.sqlmo = "Select amflib6.momast.ordno, fitem, fdesc, citem, isqty, ostat, opstc, wkctr, opseq From amflib6.momast" +
>" Join amflib6.modata On amflib6.modata.ordno = amflib6.momast.ordno" +
>" Join amflib6.morout On amflib6.morout.ordno = amflib6.momast.ordno" +
>" Where fitem = '" + arg1.trim().toUpperCase() +
>"'And (opstc = '20' Or opstc = '30') And isqty > 0 And ostat < 45";
>
Don't use them as string, format as
TEXT TO lcSQL TEXTMERGE NOSHOW
  (Select amflib6.momast.ordno, fitem, fdesc, citem, isqty, ostat, opstc, wkctr, opseq From amflib6.momast 
 Join amflib6.modata On amflib6.modata.ordno = amflib6.momast.ordno 
 Join amflib6.morout On amflib6.morout.ordno = amflib6.momast.ordno
 Where fitem = '<<arg1.trim().toUpperCase() >> ' 
And (opstc = '20' Or opstc = '30') And isqty > 0 And ostat < 45)
ENDTEXT
for readability.

Your problem is simply solved with derived tables.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform