1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

bool/boolean

Discussion in 'SQL PL/SQL' started by monkey, Jun 7, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!!!
    Bool/boolean is not temporarily usable in oracle?
    can we use anything "better" then char/varchar/varchar2 instead?
    Many thanks!
     
  2. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    BOOLEAN is not a table data type, but it is available as a PL/SQL data type. Define 'better'.
     
    monkey likes this.
  3. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Many thanks!
    What is tabke data type? Can someone give me simplest example where we can use it and wher enot?

    I tried to put it as a type in a table and it did nto go, so that is proibably what You ment??

    create table(
    id int,
    name varchar2(10),
    passed_exam bool/boolena
    );

    This did not go.
     
  4. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Where we can't use it ?
    => You just gave an example based on what Matthew has highlighted - you cannot use BOOLEAN as a table data type, in other words, in defining the column type of table.

    Where you can use it ?
    => In a PL/SQL program, where you can define a variable of type BOOLEAN - which stores logical values (TRUE / FALSE) + or course, NULL.

    A simple example from Oracle:

    Code (SQL):
    CREATE PROCEDURE print_boolean (b BOOLEAN)
    AS
    BEGIN
      DBMS_OUTPUT.put_line (
        CASE
          WHEN b IS NULL THEN 'Unknown'
          WHEN b THEN 'Yes'
          WHEN NOT b THEN 'No'
        END
      );
    END;
    /
    BEGIN
      print_boolean(TRUE);
      print_boolean(FALSE);
      print_boolean(NULL);
    END;
    /
    Results:
     
    monkey likes this.
  5. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Ooo, super, many many thanks, Rajen!!!