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

Home -> Community -> Usenet -> c.d.o.server -> Re: Value of True and False

Re: Value of True and False

From: JG <jan.grootveld_at_freeler.nl>
Date: Thu, 18 Nov 1999 00:16:12 +0100
Message-ID: <942880881.689681@samba.news.big-orange.net>


In PL/SQL an expression can evaluate to null. In that case the ELSE branch of the IF statement is entered. To trap this feature either: - test TRUE and FALSE explicitly and trap NULL with an ELSE branch, or
- test TRUE in the IF branch and evaluate al other values (including NULL) into FALSE using an ELSE branch.

this traps al possible values.

JG

Kenneth C Stahl <BlueSax_at_Unforgettable.com> schreef in berichtnieuws 382C2CC1.522EB2D2_at_Unforgettable.com...
> jason wrote:
> >
> > Thankyou both for your answers.
> > I gather the general rule is to use 0 and 1. It has since been decided,
> > though, that we'll use 0 and -1 due to VB using -1 (as Gerd pointed out
that
> > Access also does) - and a change in the value used would grately affect
alot
> > of VB code as opposed to a minimum number of Oracle SP's.
> > Thanks again fr your help chaps.
> > Jason
> >
> > jason wrote in message <80bmsk$3ba$1_at_trinitech.demon.co.uk>...
> > >Hi,
> > >Could someone please tell me the default value for True in Oracle ?
> > >We're using 0 for False; and some of us have been using -1 for True,
but
> > >some have been using 1.
> > >Also, is there a Boolean datatype in Oracle, because we've just been
using
> > a
> > >Number(1) but have now come to the problem mentioned above.
> > >
> > >(I'm on 8.04 - just incase there have been recent developments in
datatypes
> > >supported Oracle).
> > >
> > >TIA
> > >Jason
> > >
> > >
>
> There is a general convention which will always make it work right no
> matter which value for TRUE is used. Simply make all tests against FALSE.
> To illustrate this, say that I have a function defined like this in
PL/SQL:
>
> Function MyFunc Return Boolean is
> Begin
> If (some_condition)
> Return(True)
> Else
> Return(False)
> End if;
> End;
>
> Then I'd always check for the return value like this:
>
> Result boolean;
>
> Result = Myfunc;
>
> If Result = False Then
> /* code */
> Else
> /* code */
> End if;
>
> or
>
> If Result != False Then
> /* code */
> Else
> /* code */
> End if;
>
> This type of technique should work in any language and would always be
> correct no matter what the definition of TRUE is.
Received on Wed Nov 17 1999 - 17:16:12 CST

Original text of this message

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