Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to typecase a numeric type
Message
From
17/07/1997 10:57:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/07/1997 01:27:49
Shihchau Tai
Apic Systems Pte Ltd
Singapore, Singapore
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00040343
Message ID:
00040406
Views:
41
>It works. Thx.
>
>In fact, I just multiply by 1 at both the SELECT and it works. Any reason for multiplying and dividing the big number. It seems to make the field big.
>
>
I realy don't know why they designed it that way but sometimes this odd behaviour can drive you crazy if you don't use this silly (and it works !) solution. One example is storing all earnings and payments in one field using another as a flag.

Amount Flag
100000 Income
200000 Payment
200000 Income
......

select iif(flag = "Income", 1,0)*amount as Income, iif(flag = "Income", 0,1)*amount as Payments

leads to many income and 0 payment (or reverse if the first is Payment). Again using a big number enough as a multiplier instead of 1 resolves the problem (even if in VFP5 it's still like that). And this behaviour is true for character fields that are based on an expression rather than a field (and I use padr() or something like that for those).
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform