Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sqlserver CASE WHEN.. THEN ... END doesn't work with vfp
Message
De
17/01/2011 14:31:49
 
 
À
17/01/2011 03:59:54
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 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01496269
Message ID:
01496380
Vues:
91
>here is the sqlserver script that create the table DETMVT
>
>CREATE TABLE [dbo].[DETMVT](
> [NUMDET] [int] NULL,
> [NUMMVT] [int] NULL,
> [MVTDET] [int] NULL,
> [NUMCPT] [int] NULL,
> [RUBCPT] [int] NULL,
> [MONTANT] [money] NULL,
> [SENS] [int] NULL,
> [GROUPE] [int] NULL,
> [SOLDE] [money] NULL,
> [SUPRIME] [bit] NULL
>) ON [PRIMARY]
>
>here is the VFP LOCAL VIEW i want convert into REMOTE VIEW
>
>SELECT SUM(IIF(Detmvt.sens=1,Detmvt.montant,Detmvt.montant*0)) AS debit,;
> SUM(IIF(Detmvt.sens=2,Detmvt.montant,Detmvt.montant*0)) AS credit;
> FROM detmvt
>
>REMOTE VIEW
>
>SELECT SUM(CASE WHEN Detmvt.sens=1 THEN Detmvt.montant ELSE Detmvt.montant*0 END) AS debit,;
> SUM(CASE WHEN Detmvt.sens=2 THEN Detmvt.montant ELSE Detmvt.montant*0 END ) AS credit;
> FROM detmvt
>
>error message sent by vfp after this code : FUNCTION NAME IS MISSING ).

Try this :
SELECT ;
SUM(CASE WHEN sens=1 THEN montant ELSE 0 END) AS debit,  ;
SUM(CASE WHEN sens=2 THEN montant ELSE 0 END ) AS credit  ;
FROM detmvt
Notice there is a space after credit ( or put one before FROM )

Since you allow nulls for sens and montant that may be causing a problem as well if you have any null values in either one. If you try the code above and still errors you should try testing for nulls as well. ( better to not allow them in those fields if you really don't need them )

I see you allow nulls in all your fields - do you really not have a primary key field ?


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform