Home » SQL & PL/SQL » SQL & PL/SQL » Boolean Datatype
Boolean Datatype [message #162043] Wed, 08 March 2006 06:28 Go to next message
orajamzs
Messages: 110
Registered: February 2006
Location: hyderabad
Senior Member
What is logical datatype used in Oracle.

SQL> create table stdt(adno  number(4), paid boolean);
create table stdt(adno  number(4), paid boolean)
                                        *
ERROR at line 1:
ORA-00902: invalid datatype
Re: Boolean Datatype [message #162047 is a reply to message #162043] Wed, 08 March 2006 07:06 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Sadly enough, there is none. Use a 'Y/N flag'. You can add a check constraint to limit the acceptable values to 'Y' and 'N'.

MHE
Re: Boolean Datatype [message #162111 is a reply to message #162047] Wed, 08 March 2006 17:48 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Useful as a Boolean type would be in SQL, I think it would introduce some syntactic weirdness. For example,

[Not a real query]

SELECT (1 = (2 - 1)) AS result
FROM   dual
WHERE  ('hatstand' = 'banana') = (1 > 2);

should presumably return 'TRUE', or its NLS_BOOLEAN_LANGUAGE translation.

[Updated on: Thu, 09 March 2006 03:16]

Report message to a moderator

Re: Boolean Datatype [message #162132 is a reply to message #162111] Wed, 08 March 2006 21:32 Go to previous messageGo to next message
orajamzs
Messages: 110
Registered: February 2006
Location: hyderabad
Senior Member
Thanks you Mr. Maaher and Mr.Williamson for suggestions and all.
I ran same query to test, but countered following erroy ,why?
SQL> SELECT (1 = (2 - 1)) AS result
  2  FROM   dual
  3  WHERE  ('hatstand' = 'banana') = (1 > 2);
SELECT (1 = (2 - 1)) AS result
          *
ERROR at line 1:
ORA-00907: missing right parenthesis
Re: Boolean Datatype [message #162204 is a reply to message #162132] Thu, 09 March 2006 03:12 Go to previous message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
I made that syntax up to demonstrate the type of query you would see if SQL supported Booleans, which it currently does not.

[Updated on: Thu, 09 March 2006 03:17]

Report message to a moderator

Previous Topic: Update problem
Next Topic: Output to file
Goto Forum:
  


Current Time: Wed Aug 06 14:22:49 CDT 2025