Solved

Take a result set and cast a column as BOOLEAN - the field MUST be Boolean

Posted on 2008-09-30
7
709 Views
Last Modified: 2013-12-09
I have a database table in Firebird which doesn't have a Boolean datatype, so the fiels is actually of type VARCHAR(5) and the values are all "True" and "False" (strings).
Unfortunately my application uses a 3rd party component which no longer works now that the fields aren't Boolean - I think it HAS TO MAP to Boolean fields.
I've already spent about 5 hours going through hundreds of lines of code trying to rewire it to accept the VARCHAR fields - WHEN I HAD AN IDEA - couldn't I have some kind of a temporary DataSet where I could pump the resultset so that the column is BOOLEAN?

The only way that *I* know how to do this would be to set up a table in ANOTHER database like MSaccess or BDE and pump the data there - do you know of a better way?
0
Comment
Question by:rfwoolf
7 Comments
 
LVL 28

Assisted Solution

by:ciuly
ciuly earned 125 total points
Comment Utility
here are a few solutions:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21894525.html (obviously you modify the IIF condition accordingly :) )
or
select cast( <column> as bool/boolean) from table
or
select cast <column> as bool/boolean from table
convert function

or anything else that resembles this. I never worked with firebird so I can't say. but testing would show which works. but I think at least the first solution will work. according to google, the second solution should work too
0
 

Accepted Solution

by:
somosnones earned 250 total points
Comment Utility
Add a calculated field to the dataset with boolean datatype.
Handle the OnCalcFields event of the dataset to assign the boolean value to the calculated field

procedure TForm1.DataSetCalcFields(DataSet: TDataSet);
begin
  DataSetBoolField.AsBoolean := SameText(DataSetVarcharField.AsString, 'true');
end;
0
 
LVL 19

Expert Comment

by:NickUpson
Comment Utility
typically boolean is really a smallint that only holds 2 values
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 125 total points
Comment Utility
this could probably solve your problem:
http://www.devrace.com/en/fibplus/articles/473.php
http://www.delphi3000.com/articles/article_2403.asp

but you will need the FIB Components ...

this is a tool to help with the conversion
http://cc.codegear.com/Item.aspx?id=16691

or define the Boolean Domain:
http://www.firebirdfaq.org/faq12/

or switch to version 7 interbase which does support boolean data type.
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
Thanks so much for some very interesting solutions - somosnones the calculated field idea is a great one - I'm yet to try it - and rather disappointed that I didn't think of that myself. Actually I did list it as one of the things to try but never got round to it
-ciuly I have tried the CAST AS function and can't get it to work - I think it's only for the WHERE clause e.g. WHERE (CAST MyStringField AS DATE) = 01/10/2008
-Geert Gruwez - so glad I found out that FIB components can  do TFields that are decendants of TBooleanFields - that is a GREAT find - unfortunately the cost of the components will take a VERY SIGNIFICANT chunk from my renumeration - but I'm thinking about it.!!!
Thanks so much - I will get back to you as soon as I can try it...
0
 
LVL 13

Author Closing Comment

by:rfwoolf
Comment Utility
Thanks for all the help!
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
Thanks for all the help. In the end I went with a Calculated Field idea from somosnones. The FIB components would have been easier but they cost too much.
I finally did get my 3rd party components working but it has taken me a week!!! :D
 
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now