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: Value of True and False

Re: Value of True and False

From: Kenneth C Stahl <BlueSax_at_Unforgettable.com>
Date: Fri, 12 Nov 1999 10:05:37 -0500
Message-ID: <382C2CC1.522EB2D2@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 Fri Nov 12 1999 - 09:05:37 CST

Original text of this message

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