Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you use CASE statement in SELECT clause
Message
De
28/01/2009 20:07:36
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01377873
Message ID:
01377950
Vues:
16
>Can you use a CASE statement in a VFP query (similar to SQL Server)? If not, what is the best way to populate a field if it is empty when running a query? I want it to have something like 'View Record' if the field is empty or the field value if there is something in the field. Hopefully this makes sense. Thanks.
>
>Doug

Isn't there a function like EVL()? I don't have Visual FoxPro handy right now, but that should be simpler than an IIF(). I think it would be similar to NVL(). (When you do an outer join, the records from one table that have no match in the other table have null fields for the other table.)

Craig Berntson mentioned that you can't really trust the size of the resulting field. This can be solved as follows:

The old-fashioned way: If EVL() works the way I am guessing, that would be something like evl(MyField, space(10)) - assuming the field has 10 spaces. Or for a numeric, evl(MyField, 0000000000). Or replace with an iif().

In VFP 9, this would be simpler, and more under your control, with the cast() function.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform