Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using expression in ORDER BY clause
Message
 
 
À
19/10/2001 16:50:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00570371
Message ID:
00571351
Vues:
19
Hy Andrus,

I have no more knowledge about internals of VFP than you do. I can only speculate how it works based on my expirience.

>1. If numeric expression works, why the following code will not work:
>norder = 1
>CREATE CURSOR test ( test c(1) )
>SELECT * from test ORDER BY 0+norder
>Result: SQL: ORDER BY clause is invalid Why ?


It seems that foxpro decides if value in ORDER BY clause is numeric expression or column name based on the first two characters. If the first character is a digit or the first chatacter is +/- sign and the second character is a digit than it's numeric expression. Otherwise it's a column name. For the numeric expression foxpro expects only numbers and operators +,-,*,/. Anything else will generate an error. The ORDER BY clause '0+norder' from your example above is invalid from foxpro point of view.

>2. If I'm using name expression why the following code will not work:
>CREATE CURSOR test ( test c(1) )
>SELECT * from test ORDER BY ('test')
>Result: SQL: Column '' not found error. Why ?


Foxpro doesn't expect name expression in Group By clause. As I explained above if it's not a numeric expression than it's column name.

< snip >

The bottom line, that's the way foxpro parses ORDER BY clause now. Theoreticaly, it could be changed in the future versions of foxpro and both your examples could became valid.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform