Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: boolean in caluclations

Re: boolean in caluclations

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: 29 May 2007 21:54:22 -0700
Message-ID: <1180500862.700175.262130@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 Received on Tue May 29 2007 - 23:54:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US