Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Storing a SQL statement within a char variable
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01038883
Message ID:
01038897
Vues:
21
Irene,

What error are you getting? Strings can be as long as you want. You can't have a literal that exceeds a certain length. So you just have to break up you string into smaller chunks:
cSelect = 'SELECT pa_code,pa_pocode,SUM(lh_rnetkg) net,SUM(lh_bales) bales,SUM(ct_chg1) omchg,lh_rxdate '
cSelect = 'FROM bkwppacc LEFT JOIN bkwplot ON pa_code=lh_pcode LEFT join bkwpcor ON lh_recno=ct_lhrecno '
cWhere = 'WHERE BETWEEN(pa_code,"5A%","5Z%") ' + ALLTRIM(cCriteria)
cRest = ' ORDER BY 1,2,6 DESC GROUP BY 1,2,6 INTO CURSOR cntrcurs noconsole'

cSQL = cSelect + cWhere + cRest
&cSQL
One question, though. The % you are using in your BETWEEN(), is that because your data (pa_code) actually contains percent symbols or are you trying to do wildcard searches? If it's the latter, I don't think you can do it like that and get the expected results. The way you need to do it is:
BETWEEN(LEFT(pa_code, 2), '5A', '5Z')
Or you can use the SQL BETWEEN clause:
LEFT(pa_code, 2) BETWEEN '5A' AND '5Z'
Or you can use a LIKE clause to get all pa_codes that start with a 5:
pa_code LIKE '5%'
HTH,
Chad


>Depending on the options selected on the front-end, a selection criteria is build. In the end the cSelect, cWhere and cRest is combined into a variable cSQL.
>
>-----------------
>cSelect = 'SELECT pa_code,pa_pocode,SUM(lh_rnetkg) net,SUM(lh_bales) bales,SUM(ct_chg1) omchg,lh_rxdate ' + ;
> 'FROM bkwppacc LEFT JOIN bkwplot ON pa_code=lh_pcode LEFT join bkwpcor ON lh_recno=ct_lhrecno '
>cWhere = 'WHERE BETWEEN(pa_code,"5A%","5Z%") ' + ALLTRIM(cCriteria)
>cRest = 'ORDER BY 1,2,6 DESC GROUP BY 1,2,6 INTO CURSOR cntrcurs noconsole '
>
>cSQL = cSelect + cWhere + cRest
>&cSQL
>-----------------
>
>It looks like the variable cSQL cannot store the entire info. What can I use if the characters to store is greater than 254?
>
>Irene
_________________________________
There are 2 types of people in the world:
    Those who need closure
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform