Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IIF character length?
Message
De
03/06/2002 08:25:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/06/2002 08:14:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00663995
Message ID:
00664002
Vues:
23
>I'm using the following statement in SQL: (VFP 5.0, selecting from a foxpro database.)
>
>select a.citat as TICKUPD, IIF(a.pflag=.t.,"T","F") as CASE_FLAG, IIF(a.acc=.t.,"Y","N") as ACC, ;
>a.chem, IIF(empty(a.dtrefu),"''","'" + DTOC(a.dtrefu) + "'") as DTREFU, ;
>IIF(empty(a.dtdisp),"''","'" + DTOC(a.dtdisp) + "'") as GFC_DDATE, ;
>IIF(INLIST(a.DISPO,"1","2","7"),a.DISPO,"") as MAST_DISPO, ;
>IIF(empty(a.dtcompl),"''","'" + DTOC(a.dtcompl) + "'") as DTCOMPL, ;
>a.MECOMPL, ;
>IIF(a.CANID=.t.,"Y","N") as CANID, IIF(empty(a.dtsent),"''","'" + DTOC(a.dtsent) + "'") as DTSENT, ;
>IIF(empty(a.dtadd),"''","'" + DTOC(a.dtadd) + "'") as DTADD, ;
>IIF(empty(a.dtchange),"''","'" + DTOC(a.dtchange) + "'") as DTCHANGE, b.tick_num from mevmast
>
>For some reason, the results it is giving me for the date fields DTCOMPL, DTSENT, DTADD and DTCHANGE are coming out as two characters long-- i.e. if the date value is 02/05/1999 the result of the IIF seems to become '0
>If it is 11/15/2000 it becomes '1
>And so on. However, the GFC_DDATE IIF which is written identically works fine. Any ideas?

Tom,
It's not the iif() itself. When SQL is creating the cursor (and I suspect this is VFP5) it sets the width of the column to the first result's width on that column. ie : If you used alltrim(SomeField) as MyField and in selected set Somefield was 'Tom' that column would be 3 chars width and 'William' would be 'Wil'. To workaround pad your expression. ie: For a date field you could use transform(dtoc(ddate,1),'@R 9999/99/99').

PS: As I pressed send I saw your saying 'VFP5.0' :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform