Home » SQL & PL/SQL » SQL & PL/SQL » how to create boolean data type in oracle?? (oracle 10g)
how to create boolean data type in oracle?? [message #428031] Mon, 26 October 2009 23:23 Go to next message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
I need to make a boolean type column..but there is no boolean type in oracle. how can i do that?
Re: how to create boolean data type in oracle?? [message #428032 is a reply to message #428031] Mon, 26 October 2009 23:27 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
abhi_shakya wrote on Mon, 26 October 2009 21:23
I need to make a boolean type column..but there is no boolean type in oracle. how can i do that?


NEW_BOOL VARCHAR2(5)
valid values are either 'TRUE' or 'FALSE'
Re: how to create boolean data type in oracle?? [message #428033 is a reply to message #428032] Mon, 26 October 2009 23:32 Go to previous messageGo to next message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
please help me by explaining it..
Re: how to create boolean data type in oracle?? [message #428048 is a reply to message #428031] Tue, 27 October 2009 00:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
If there is no boolean datatype, you can use a boolean datatype, so you have to simulate from another one.
BlackSwan gave you an example.

Regards
Michel
Re: how to create boolean data type in oracle?? [message #428067 is a reply to message #428033] Tue, 27 October 2009 01:33 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

Why dont you create a varchar2 column with check constraint?.
allowed values would be True and False.
Re: how to create boolean data type in oracle?? [message #428079 is a reply to message #428031] Tue, 27 October 2009 03:10 Go to previous messageGo to next message
jigs230678
Messages: 3
Registered: October 2009
Location: Mumbai
Junior Member

Hi,

In case not having bollen data type, you can still implement your logic by using VARCHAR2 data type. Steps are given below.

1) Create one variable/column in table with VARCHAR2 data type.
2) Create CHECK CONSTRAINT for 'T' or 'F' or 'TRUE' or 'FALSE' to restrict values in it. In case of variable, write IF condition to restrict value.
3) Use this column/variable in your code.

Let me know above has not answered your query.

Regards,
Jignesh
Re: how to create boolean data type in oracle?? [message #428129 is a reply to message #428079] Tue, 27 October 2009 05:45 Go to previous messageGo to next message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
thank u everyone..i have done that using number data type 0 and 1..
thanks for the suggestion...
Re: how to create boolean data type in oracle?? [message #428161 is a reply to message #428129] Tue, 27 October 2009 06:50 Go to previous message
Michel Cadot
Messages: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Don't forget to put a check constraint on your column then the values can only be 0 or 1.

Regards
Michel
Previous Topic: select query giving exception
Next Topic: Foreign key constraint error
Goto Forum:
  


Current Time: Mon Dec 09 21:17:23 CST 2024