×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Strange Question About Boolean Data Types In Sql...

Strange Question About Boolean Data Types In Sql...

Strange Question About Boolean Data Types In Sql...

(OP)
Hi guys,

I was using SQL to create a field called "StatusofTarget" (status of target) .....

i want the data type for this field to be boolean so that the boolean values can be set as either "COMPLETED" or "PROGRESSING"... but i realised that SQL in interbase doesnt recognise BOOLEAN data type...
is there a way to set boolean data types for fields?

"StatusofTarget           boolean          Not Null,"

doesnt work in sql..

 please can you tell me how to set BOOLEAN data types in sql ... and the two values to be "COMPLETED" or "PROGRESSING" instead of YES/NO or True/False

RE: Strange Question About Boolean Data Types In Sql...

COMPLETED and PROGRESSING are more of a status type, not a boolean.  Use of a Boolean field is more like...
COMPLETED - yes / no

And SQL statement would be more like...
SELECT ... FROM ... WHERE Completed = True
(The definition of a boolean field is true/false, the yes/no thing is so that it is more easily understood by some)

vs...
SELECT ... FROM ... WHERE StatusofTarget = "Completed"

As for creating the boolean field in Interbase, can't help you there.  My approach, it creating tables programmatically, with VBA for Access...

CODE

Function CreateATable() As Boolean

Dim dbs As DAO.Database, tdf As TableDef
Dim fld As Field, idx As Index

Set dbs = CurrentDb()

Set tdf = dbs.CreateTableDef("tblYourTable")

With tdf
    .Fields.Append .CreateField("YourPKTextField1", dbText, 10)
    .Fields.Append .CreateField("YourIntegerField1", dbInteger)
    .Fields.Append .CreateField("YourBooleanField1", dbBoolean)
    .Fields.Append .CreateField("YourLongIntField1", dbLong)
    .Fields.Append .CreateField("YourSingleField1", dbSingle)
    .Fields.Append .CreateField("YourDateField1", dbDate)
End With


'Other date types:
' dbBigInt  dbBinary  dbByte   dbChar   dbCurrency    dbDouble
' dbFloat   dbGUID    dbMemo   dbTime   dbLongBinary  dbTimeStamp
' dbVarBinary

dbs.TableDefs.Append tdf
Set idx = tdf.CreateIndex("PrimaryKey")
'Set fld = idx.CreateField("YourPKTextField1")
idx.Fields.Append idx.CreateField("YourPKTextField1")
idx.Primary = True
idx.Unique = True
tdf.Indexes.Append idx

CreateATable = True

End Function

Richard

RE: Strange Question About Boolean Data Types In Sql...

Quote:

the boolean values can be set as either "COMPLETED" or "PROGRESSING"

Don't use boolean. Store them as CHAR(11). It will take more space but you'll be very glad you did when the user asks you to add a "CANCELLED" category.

Geoff Franklin
www.alvechurchdata.co.uk

RE: Strange Question About Boolean Data Types In Sql...

(OP)
thx a lot:)

but i dont want the user to be able to enter any more values other than  progressing or completed so how will  char do  this?

RE: Strange Question About Boolean Data Types In Sql...

[quote]but i dont want the user to be able to enter any more values other than  progressing or completed so how will  char do  this?{/quote]
Char won't do this by itself. You'll have to add some sort of validation to the field to restrict its values.

Geoff Franklin
www.alvechurchdata.co.uk

RE: Strange Question About Boolean Data Types In Sql...

(OP)
what's a check constraint... and how does it work please....

RE: Strange Question About Boolean Data Types In Sql...

(OP)
im sorry for asking  so many questions

i do not have an iterbase manual but im trying to get one

ive searched on the net  for some of my problems but its hard to find what im looking for

thnx

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close