Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datatype ???
Message
From
26/01/2000 06:42:33
 
 
To
26/01/2000 05:04:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00322685
Message ID:
00322701
Views:
22
>Hello,
>
>here's the situation:
>
>I do have a select statement:
>
>SELECT t.*, (t.number*t.price) * iif(t.transs = ""CS"" OR t.transs = ""DV"" OR t.transs = ""L "" OR t.transs = ""R "" OR t.transs = ""RC"" OR t.transs = ""RD"" OR t.transs = ""V "" OR t.transs = ""ST"" OR t.transs = ""OP"" , 1, -1) as bruto from trans t
>
>It gives me the following result for bruto:
>
>912414,12124
>12421
>111, 12425235
>etc.
>
>Cause these are all amounts I would like to have just 2 places behind the comma. I tried
>
>SELECT t.*, (t.number*t.price) * iif(t.transs = ""CS"" OR t.transs = ""DV"" OR t.transs = ""L "" OR t.transs = ""R "" OR t.transs = ""RC"" OR t.transs = ""RD"" OR t.transs = ""V "" OR t.transs = ""ST"" OR t.transs = ""OP"" , 1, -1)+00000000,00 as bruto from trans t
>
>and that gives me all 0
>
>I changed the comma into a dot and yet it gives me all the numbers behind the comma.
>
>Any other suggestions ?
>

Aside from shooting the person who hardcoded this list of values, skinning them, strapping them nekkid out on an anthill on a blistering hot, sticky day and forcing them to have really whiny users add, change or subtly alter an average of 2.347 codes per week, no two versions with quite the same list, and each user wanting you to add 'their' special code just for their run?

Wrap the sick second expression in ROUND( blah blah woof woof, 2).

Hint - if nothing else, at least get rid of the freaking ORs and crap and use INLIST(), making it semi-readable and not a clear sign of impending brain death, just waiting to fall off the nearest cliff. Better would be to use a nice IN clause and make the thing readable and maintainable. But it's your code, not mine.

And these are the suggestions when I'm being charitable. I'd be hard pressed to make it perform worse or make it less maintainable if I tried hard. Seriously. Doesn't
IIF(INLIST(t.transs,'"CS"','"DV"','"L "', '"R "','"RC"', '"RD"','"V "','"ST"','"OP"'),1,-1)
at least look semi-sane and extensible? (INLIST() can only have up to 24 values, it is not optimizable, but it's infinitely better than the original)

Can you really look at the original code and admit you wrote it publicly?

A name change, plastic surgery and entering a monastery for 20-30 years might work.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform