Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: boolean in caluclations
"Vladimir M. Zakharychev" <vladimir.zakharychev_at_gmail.com> a écrit dans le message de news:
1180500862.700175.262130_at_q69g2000hsb.googlegroups.com...
On May 30, 8:35 am, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
> "jobs" <j..._at_webdos.com> a écrit dans le message de news: 1180467609.765964.202..._at_p47g2000hsd.googlegroups.com...
> | how can i do this in pl-sql?
> |
> | when lines=2 that is replaced by a 1 allowing that math to take place
> |
> | when lines>2 it adds the other piece instead. Trying to avoid if
> | statements.
> |
> | fee := (fixed_mf + ((lines=2)* lines_2) +
> | (((lines>2)*(lines-1))*lines_more));
> |
> | thanks for any help or information.
> |
>
> (lines = 2) returns TRUE or FALSE.
> How can you multiply that by lines_2?
>
> What should be the result of 2*TRUE?
>
> Regards
> Michel Cadot
Twice as true as conventional TRUE? :) Seriously, the OP says that when lines=2, this should be replaced by 1 (in other words, ignored.) This can be done with a searched CASE:
fee := fixed_mf +
CASE
WHEN lines=2 THEN lines_2
WHEN lines>2 THEN (lines-1)*lines_more
END;
Hey, no IFs, just as the OP wanted! :)
Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
I understand what it means but there is no reason for TRUE to be 1.
In C specifications, is TRUE any not 0 value?
I worked in an OS where TRUE was xFFFFFFFFF, or was it FALSE
I don't remember but both is valid.
What if Oracle choose to represent TRUE with 0 and FALSE with 1.
I mean numeric operation upon boolean values is meaningless.
SQL> declare i integer;
2 begin
3 i := 1 +
4 case 5 when 1=2 then 1 6 when 1=1 then 2 7 end;
PL/SQL procedure successfully completed.
This works (as you said).
Regards
Michel Cadot
Received on Wed May 30 2007 - 10:43:18 CDT
![]() |
![]() |